public final class HttpHeaderUtil extends Object
Modifier and Type | Method and Description |
---|---|
static long |
getContentLength(HttpMessage message)
Returns the length of the content.
|
static long |
getContentLength(HttpMessage message,
long defaultValue)
Returns the length of the content.
|
static boolean |
is100ContinueExpected(HttpMessage message)
Returns
true if and only if the specified message contains the
"Expect: 100-continue" header. |
static boolean |
isContentLengthSet(HttpMessage m) |
static boolean |
isKeepAlive(HttpMessage message)
Returns
true if and only if the connection can remain open and
thus 'kept alive'. |
static boolean |
isTransferEncodingChunked(HttpMessage message)
Checks to see if the transfer encoding in a specified
HttpMessage is chunked |
static void |
set100ContinueExpected(HttpMessage message,
boolean expected)
Sets or removes the
"Expect: 100-continue" header to / from the
specified message. |
static void |
setContentLength(HttpMessage message,
long length)
Sets the
"Content-Length" header. |
static void |
setKeepAlive(HttpMessage message,
boolean keepAlive)
Sets the value of the
"Connection" header depending on the
protocol version of the specified message. |
static void |
setTransferEncodingChunked(HttpMessage m,
boolean chunked) |
public static boolean isKeepAlive(HttpMessage message)
true
if and only if the connection can remain open and
thus 'kept alive'. This methods respects the value of the
"Connection"
header first and then the return value of
HttpVersion.isKeepAliveDefault()
.public static void setKeepAlive(HttpMessage message, boolean keepAlive)
"Connection"
header depending on the
protocol version of the specified message. This getMethod sets or removes
the "Connection"
header depending on what the default keep alive
mode of the message's protocol version is, as specified by
HttpVersion.isKeepAliveDefault()
.
"close"
if keepAlive
is false
."keep-alive"
if keepAlive
is true
.public static long getContentLength(HttpMessage message)
ByteBufHolder.content()
but from the
"Content-Length"
header, and thus they are independent from each
other.NumberFormatException
- if the message does not have the "Content-Length"
header
or its value is not a numberpublic static long getContentLength(HttpMessage message, long defaultValue)
ByteBufHolder.content()
but from the
"Content-Length"
header, and thus they are independent from each
other.defaultValue
if this message does
not have the "Content-Length"
header or its value is not
a numberpublic static void setContentLength(HttpMessage message, long length)
"Content-Length"
header.public static boolean isContentLengthSet(HttpMessage m)
public static boolean is100ContinueExpected(HttpMessage message)
true
if and only if the specified message contains the
"Expect: 100-continue"
header.public static void set100ContinueExpected(HttpMessage message, boolean expected)
"Expect: 100-continue"
header to / from the
specified message. If the specified value
is true
,
the "Expect: 100-continue"
header is set and all other previous
"Expect"
headers are removed. Otherwise, all "Expect"
headers are removed completely.public static boolean isTransferEncodingChunked(HttpMessage message)
HttpMessage
is chunkedmessage
- The message to checkpublic static void setTransferEncodingChunked(HttpMessage m, boolean chunked)
Copyright © 2008–2015 The Netty Project. All rights reserved.