public class DefaultHttpMessage extends Object implements HttpMessage
HttpMessage implementation.| Modifier | Constructor and Description |
|---|---|
protected |
DefaultHttpMessage(HttpVersion version)
Creates a new instance.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addHeader(String name,
Object value)
Adds a new header with the specified name and value.
|
void |
clearHeaders()
Removes all headers from this
HttpMessage. |
boolean |
containsHeader(String name)
Checks to see if there is a header with the specified name
|
io.netty.buffer.ByteBuf |
getContent()
Returns the content of this
HttpMessage. |
String |
getHeader(String name)
Returns the value of a header with the specified name.
|
Set<String> |
getHeaderNames()
Gets a
Set of all header names that this message contains |
List<Map.Entry<String,String>> |
getHeaders()
Returns the all headers that this message contains.
|
List<String> |
getHeaders(String name)
Returns the values of headers with the specified name
|
HttpVersion |
getProtocolVersion()
Returns the protocol version of this
HttpMessage |
HttpTransferEncoding |
getTransferEncoding()
Returns the transfer encoding of this
HttpMessage. |
void |
removeHeader(String name)
Removes the header with the specified name.
|
void |
setContent(io.netty.buffer.ByteBuf content)
Sets the content of this
HttpMessage. |
void |
setHeader(String name,
Iterable<?> values)
Sets a header with the specified name and values.
|
void |
setHeader(String name,
Object value)
Sets a header with the specified name and value.
|
void |
setProtocolVersion(HttpVersion version)
Sets the protocol version of this
HttpMessage |
void |
setTransferEncoding(HttpTransferEncoding te)
Sets the transfer encoding of this
HttpMessage. |
String |
toString() |
protected DefaultHttpMessage(HttpVersion version)
public void addHeader(String name, Object value)
HttpMessageString, it is converted
into a String by Object.toString(), except in the cases
of Date and Calendar, which are formatted to the date
format defined in RFC2616.addHeader in interface HttpMessagename - The name of the header being addedvalue - The value of the header being addedpublic void setHeader(String name, Object value)
HttpMessageString, it is converted into a
String by Object.toString(), except for Date
and Calendar, which are formatted to the date format defined in
RFC2616.setHeader in interface HttpMessagename - The name of the header being setvalue - The value of the header being setpublic void setHeader(String name, Iterable<?> values)
HttpMessage
m.removeHeader(name);
for (Object v: values) {
if (v == null) {
break;
}
m.addHeader(name, v);
}
setHeader in interface HttpMessagename - The name of the headers being setvalues - The values of the headers being setpublic void removeHeader(String name)
HttpMessageremoveHeader in interface HttpMessagename - The name of the header to removepublic HttpTransferEncoding getTransferEncoding()
HttpMessageHttpMessage.
HttpTransferEncoding.CHUNKED - an HTTP message whose "Transfer-Encoding"
is "chunked".HttpTransferEncoding.STREAMED - an HTTP message which is not chunked, but
is followed by HttpChunks that represent its content. HttpMessage.getContent()
returns an empty buffer.HttpTransferEncoding.SINGLE - a self-contained HTTP message which is not chunked
and HttpMessage.getContent() returns the full content.getTransferEncoding in interface HttpMessagepublic void setTransferEncoding(HttpTransferEncoding te)
HttpMessageHttpMessage.
HttpTransferEncoding.CHUNKED, the "Transfer-Encoding: chunked"
header is set and the "Content-Length" header and the content of this message are
removed automatically.HttpTransferEncoding.STREAMED, the "Transfer-Encoding: chunked"
header and the content of this message are removed automatically.HttpTransferEncoding.SINGLE, the "Transfer-Encoding: chunked"
header is removed automatically.HttpTransferEncoding means, see HttpMessage.getTransferEncoding().setTransferEncoding in interface HttpMessagepublic void clearHeaders()
HttpMessageHttpMessage.clearHeaders in interface HttpMessagepublic void setContent(io.netty.buffer.ByteBuf content)
HttpMessageHttpMessage.
If null is specified, the content of this message
will be set to Unpooled.EMPTY_BUFFERsetContent in interface HttpMessagecontent - The ByteBuf containing the content to usepublic String getHeader(String name)
HttpMessagegetHeader in interface HttpMessagename - The name of the header to searchnull if there is no such headerpublic List<String> getHeaders(String name)
HttpMessagegetHeaders in interface HttpMessagename - The name of the headers to searchList of header values which will be empty if no values
are foundpublic List<Map.Entry<String,String>> getHeaders()
HttpMessagegetHeaders in interface HttpMessageList of the header name-value entries, which will be
empty if no pairs are foundpublic boolean containsHeader(String name)
HttpMessagecontainsHeader in interface HttpMessagename - The name of the header to search forpublic Set<String> getHeaderNames()
HttpMessageSet of all header names that this message containsgetHeaderNames in interface HttpMessageSet of all header namespublic HttpVersion getProtocolVersion()
HttpMessageHttpMessagegetProtocolVersion in interface HttpMessagepublic void setProtocolVersion(HttpVersion version)
HttpMessageHttpMessagesetProtocolVersion in interface HttpMessageversion - The version to setpublic io.netty.buffer.ByteBuf getContent()
HttpMessageHttpMessage.
If there is no content or HttpMessage.getTransferEncoding() returns
HttpTransferEncoding.STREAMED or HttpTransferEncoding.CHUNKED,
an Unpooled.EMPTY_BUFFER is returned.getContent in interface HttpMessageByteBuf containing this HttpMessage's contentCopyright © 2008-2012 The Netty Project. All Rights Reserved.