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)
HttpMessage
String
, 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 HttpMessage
name
- The name of the header being addedvalue
- The value of the header being addedpublic void setHeader(String name, Object value)
HttpMessage
String
, 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 HttpMessage
name
- 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 HttpMessage
name
- The name of the headers being setvalues
- The values of the headers being setpublic void removeHeader(String name)
HttpMessage
removeHeader
in interface HttpMessage
name
- The name of the header to removepublic HttpTransferEncoding getTransferEncoding()
HttpMessage
HttpMessage
.
HttpTransferEncoding.CHUNKED
- an HTTP message whose "Transfer-Encoding"
is "chunked"
.HttpTransferEncoding.STREAMED
- an HTTP message which is not chunked, but
is followed by HttpChunk
s 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 HttpMessage
public void setTransferEncoding(HttpTransferEncoding te)
HttpMessage
HttpMessage
.
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 HttpMessage
public void clearHeaders()
HttpMessage
HttpMessage
.clearHeaders
in interface HttpMessage
public void setContent(io.netty.buffer.ByteBuf content)
HttpMessage
HttpMessage
.
If null
is specified, the content of this message
will be set to Unpooled.EMPTY_BUFFER
setContent
in interface HttpMessage
content
- The ByteBuf
containing the content to usepublic String getHeader(String name)
HttpMessage
getHeader
in interface HttpMessage
name
- The name of the header to searchnull
if there is no such headerpublic List<String> getHeaders(String name)
HttpMessage
getHeaders
in interface HttpMessage
name
- 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()
HttpMessage
getHeaders
in interface HttpMessage
List
of the header name-value entries, which will be
empty if no pairs are foundpublic boolean containsHeader(String name)
HttpMessage
containsHeader
in interface HttpMessage
name
- The name of the header to search forpublic Set<String> getHeaderNames()
HttpMessage
Set
of all header names that this message containsgetHeaderNames
in interface HttpMessage
Set
of all header namespublic HttpVersion getProtocolVersion()
HttpMessage
HttpMessage
getProtocolVersion
in interface HttpMessage
public void setProtocolVersion(HttpVersion version)
HttpMessage
HttpMessage
setProtocolVersion
in interface HttpMessage
version
- The version to setpublic io.netty.buffer.ByteBuf getContent()
HttpMessage
HttpMessage
.
If there is no content or HttpMessage.getTransferEncoding()
returns
HttpTransferEncoding.STREAMED
or HttpTransferEncoding.CHUNKED
,
an Unpooled.EMPTY_BUFFER
is returned.getContent
in interface HttpMessage
ByteBuf
containing this HttpMessage
's contentCopyright © 2008-2012 The Netty Project. All Rights Reserved.