public final class HttpResponseHeaders extends Object
| Modifier and Type | Field and Description |
|---|---|
protected static byte[] |
SPACE |
| Constructor and Description |
|---|
HttpResponseHeaders(InputStream inputStream)
This creates an instance of this class by reading status line and headers from a stream
|
HttpResponseHeaders(String statusLine,
String... headers)
This creates an instance of HttpResponseHeaders
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
addHeader(String line)
Adds a header, if header header with this name already exists, it adds a new entry without deleting existing
|
void |
addHeader(String headerName,
String headerValue)
Adds a header, if header header with this name already exists, it adds a new entry without deleting existing
|
long |
getContentLength() |
String |
getHeader(String headerName)
This returns a header by name, if there are more then one header with this name, the first one will be returned
Returns null if header does not exit
|
List<String> |
getHeaders(String headerName)
This returns headers by name, if there are more then one header with this name, all of them will be returned
|
String |
getReason() |
int |
getStatusCode() |
String |
getVersion() |
boolean |
hasChunkedBody() |
List<String> |
listHeaderNames() |
static HttpResponseHeaders |
notFound() |
static HttpResponseHeaders |
ok() |
protected void |
readHeaders(serguei.http.HeaderLineReader reader)
Read headers into the stream
|
static HttpResponseHeaders |
redirectTo(String location) |
void |
removeHeader(String headerName)
Removes header with a specified name
|
static HttpResponseHeaders |
serverError() |
void |
setHeader(String headerName,
String value)
Sets header If headers with this name already exists, replaces it
|
String |
toString() |
void |
write(OutputStream outputStream)
Write headers into the stream
|
public HttpResponseHeaders(String statusLine, String... headers) throws HttpException
statusLine - - status line, e.g. "GET / HTTP/1."headers - - headers in the form "Content-Length: 100"HttpException - - can be thrown when status line or headers do not follow HTTP standardspublic HttpResponseHeaders(InputStream inputStream) throws IOException
inputStream - IOException - - thrown when the data is not HTTP or IO errorspublic static HttpResponseHeaders ok()
public static HttpResponseHeaders redirectTo(String location)
public static HttpResponseHeaders notFound()
public static HttpResponseHeaders serverError()
public void write(OutputStream outputStream) throws IOException
IOExceptionpublic String toString()
public String getVersion()
public int getStatusCode()
public String getReason()
protected void readHeaders(serguei.http.HeaderLineReader reader)
throws IOException
IOExceptionpublic String getHeader(String headerName)
public List<String> getHeaders(String headerName)
public long getContentLength()
public boolean hasChunkedBody()
protected void addHeader(String line) throws HttpException
HttpExceptionpublic void setHeader(String headerName, String value)
public void addHeader(String headerName, String headerValue)
public void removeHeader(String headerName)
Copyright © 2019. All rights reserved.