public interface HttpMessage
HttpRequest
and HttpResponse
.HttpResponse
,
HttpRequest
,
HttpHeaders
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 getHeader(String name)
name
- The name of the header to searchnull
if there is no such headerList<String> getHeaders(String name)
name
- The name of the headers to searchList
of header values which will be empty if no values
are foundList<Map.Entry<String,String>> getHeaders()
List
of the header name-value entries, which will be
empty if no pairs are foundboolean containsHeader(String name)
name
- The name of the header to search forSet<String> getHeaderNames()
Set
of all header names that this message containsSet
of all header namesHttpVersion getProtocolVersion()
HttpMessage
void setProtocolVersion(HttpVersion version)
HttpMessage
version
- The version to setio.netty.buffer.ByteBuf getContent()
HttpMessage
.
If there is no content or getTransferEncoding()
returns
HttpTransferEncoding.STREAMED
or HttpTransferEncoding.CHUNKED
,
an Unpooled.EMPTY_BUFFER
is returned.ByteBuf
containing this HttpMessage
's contentvoid setContent(io.netty.buffer.ByteBuf content)
HttpMessage
.
If null
is specified, the content of this message
will be set to Unpooled.EMPTY_BUFFER
content
- The ByteBuf
containing the content to usevoid addHeader(String name, Object value)
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.name
- The name of the header being addedvalue
- The value of the header being addedvoid setHeader(String name, Object value)
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.name
- The name of the header being setvalue
- The value of the header being setvoid setHeader(String name, Iterable<?> values)
m.removeHeader(name); for (Object v: values) { if (v == null) { break; } m.addHeader(name, v); }
name
- The name of the headers being setvalues
- The values of the headers being setvoid removeHeader(String name)
name
- The name of the header to removevoid clearHeaders()
HttpMessage
.HttpTransferEncoding getTransferEncoding()
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. getContent()
returns an empty buffer.HttpTransferEncoding.SINGLE
- a self-contained HTTP message which is not chunked
and getContent()
returns the full content.void setTransferEncoding(HttpTransferEncoding te)
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 getTransferEncoding()
.Copyright © 2008-2012 The Netty Project. All Rights Reserved.