public abstract class HttpHeaders
extends java.lang.Object
implements java.lang.Iterable<java.util.Map.Entry<java.lang.String,java.lang.String>>
HttpMessage.
Concrete instances of this class are most easily obtained from its default factory:
DefaultHttpHeadersFactory.headersFactory().
| 限定符和类型 | 类和说明 |
|---|---|
static class |
HttpHeaders.Names
已过时。
Use
HttpHeaderNames instead.
Standard HTTP header names. |
static class |
HttpHeaders.Values
已过时。
Use
HttpHeaderValues instead.
Standard HTTP header values. |
| 限定符和类型 | 字段和说明 |
|---|---|
static HttpHeaders |
EMPTY_HEADERS
已过时。
Use
EmptyHttpHeaders.INSTANCE.
The instance is instantiated here to break the cyclic static initialization between |
| 限定符 | 构造器和说明 |
|---|---|
protected |
HttpHeaders() |
| 限定符和类型 | 方法和说明 |
|---|---|
HttpHeaders |
add(java.lang.CharSequence name,
java.lang.Iterable<?> values)
Adds a new header with the specified name and values.
|
HttpHeaders |
add(java.lang.CharSequence name,
java.lang.Object value)
Adds a new header with the specified name and value.
|
HttpHeaders |
add(HttpHeaders headers)
Adds all header entries of the specified
headers. |
abstract HttpHeaders |
add(java.lang.String name,
java.lang.Iterable<?> values) |
abstract HttpHeaders |
add(java.lang.String name,
java.lang.Object value) |
static void |
addDateHeader(HttpMessage message,
java.lang.CharSequence name,
java.util.Date value)
已过时。
Use
add(CharSequence, Object) instead.
Adds a new date header with the specified name and value. The specified
value is formatted as defined in
RFC2616 |
static void |
addDateHeader(HttpMessage message,
java.lang.String name,
java.util.Date value)
已过时。
Use
add(CharSequence, Object) instead. |
static void |
addHeader(HttpMessage message,
java.lang.CharSequence name,
java.lang.Object value)
已过时。
Use
add(CharSequence, Object) instead.
Adds a new header with the specified name and value.
If the specified value is not a 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. |
static void |
addHeader(HttpMessage message,
java.lang.String name,
java.lang.Object value)
已过时。
Use
add(CharSequence, Object) instead. |
abstract HttpHeaders |
addInt(java.lang.CharSequence name,
int value)
Add the
name to value. |
static void |
addIntHeader(HttpMessage message,
java.lang.CharSequence name,
int value)
已过时。
Use
addInt(CharSequence, int) instead.
Adds a new integer header with the specified name and value. |
static void |
addIntHeader(HttpMessage message,
java.lang.String name,
int value)
已过时。
Use
add(CharSequence, Iterable) instead. |
abstract HttpHeaders |
addShort(java.lang.CharSequence name,
short value)
Add the
name to value. |
abstract HttpHeaders |
clear()
Removes all headers from this
HttpMessage. |
static void |
clearHeaders(HttpMessage message)
已过时。
Use
clear() instead.
Removes all headers from the specified message. |
boolean |
contains(java.lang.CharSequence name)
Checks to see if there is a header with the specified name
|
boolean |
contains(java.lang.CharSequence name,
java.lang.CharSequence value,
boolean ignoreCase)
Returns
true if a header with the name and value exists, false otherwise. |
abstract boolean |
contains(java.lang.String name) |
boolean |
contains(java.lang.String name,
java.lang.String value,
boolean ignoreCase) |
boolean |
containsValue(java.lang.CharSequence name,
java.lang.CharSequence value,
boolean ignoreCase)
Returns
true if a header with the name and value exists, false otherwise. |
HttpHeaders |
copy()
Returns a deep copy of the passed in
HttpHeaders. |
static void |
encodeAscii(java.lang.CharSequence seq,
ByteBuf buf)
已过时。
|
abstract java.util.List<java.util.Map.Entry<java.lang.String,java.lang.String>> |
entries()
Returns a new
List that contains all headers in this object. |
static boolean |
equalsIgnoreCase(java.lang.CharSequence name1,
java.lang.CharSequence name2)
已过时。
|
java.lang.String |
get(java.lang.CharSequence name)
Returns the value of a header with the specified name.
|
java.lang.String |
get(java.lang.CharSequence name,
java.lang.String defaultValue)
Returns the value of a header with the specified name.
|
abstract java.lang.String |
get(java.lang.String name) |
java.util.List<java.lang.String> |
getAll(java.lang.CharSequence name)
Returns the values of headers with the specified name
|
abstract java.util.List<java.lang.String> |
getAll(java.lang.String name) |
java.util.List<java.lang.String> |
getAllAsString(java.lang.CharSequence name)
|
java.lang.String |
getAsString(java.lang.CharSequence name)
Headers.get(Object) and convert the result to a String. |
static long |
getContentLength(HttpMessage message)
已过时。
Use
HttpUtil.getContentLength(HttpMessage) instead.
Returns the length of the content. Please note that this value is
not retrieved from ByteBufHolder.content() but from the
"Content-Length" header, and thus they are independent from each
other. |
static long |
getContentLength(HttpMessage message,
long defaultValue)
已过时。
Use
HttpUtil.getContentLength(HttpMessage, long) instead.
Returns the length of the content. Please note that this value is
not retrieved from ByteBufHolder.content() but from the
"Content-Length" header, and thus they are independent from each
other. |
static java.util.Date |
getDate(HttpMessage message)
已过时。
Use
getTimeMillis(CharSequence) instead.
Returns the value of the "Date" header. |
static java.util.Date |
getDate(HttpMessage message,
java.util.Date defaultValue)
已过时。
Use
getTimeMillis(CharSequence, long) instead.
Returns the value of the "Date" header. If there is no such
header or the header is not a formatted date, the defaultValue
is returned. |
static java.util.Date |
getDateHeader(HttpMessage message,
java.lang.CharSequence name)
已过时。
Use
getTimeMillis(CharSequence) instead.
Returns the date header value with the specified header name. If
there are more than one header value for the specified header name, the
first value is returned. |
static java.util.Date |
getDateHeader(HttpMessage message,
java.lang.CharSequence name,
java.util.Date defaultValue)
已过时。
Use
getTimeMillis(CharSequence, long) instead.
Returns the date header value with the specified header name. If
there are more than one header value for the specified header name, the
first value is returned. |
static java.util.Date |
getDateHeader(HttpMessage message,
java.lang.String name)
已过时。
Use
getTimeMillis(CharSequence) instead. |
static java.util.Date |
getDateHeader(HttpMessage message,
java.lang.String name,
java.util.Date defaultValue)
已过时。
Use
getTimeMillis(CharSequence, long) instead. |
static java.lang.String |
getHeader(HttpMessage message,
java.lang.CharSequence name)
已过时。
Use
get(CharSequence) instead.
Returns the header value with the specified header name. If there are
more than one header value for the specified header name, the first
value is returned. |
static java.lang.String |
getHeader(HttpMessage message,
java.lang.CharSequence name,
java.lang.String defaultValue)
已过时。
Use
get(CharSequence, String) instead.
Returns the header value with the specified header name. If there are
more than one header value for the specified header name, the first
value is returned. |
static java.lang.String |
getHeader(HttpMessage message,
java.lang.String name)
已过时。
Use
get(CharSequence) instead. |
static java.lang.String |
getHeader(HttpMessage message,
java.lang.String name,
java.lang.String defaultValue)
已过时。
Use
get(CharSequence, String) instead. |
static java.lang.String |
getHost(HttpMessage message)
已过时。
Use
get(CharSequence) instead.
Returns the value of the "Host" header. |
static java.lang.String |
getHost(HttpMessage message,
java.lang.String defaultValue)
已过时。
Use
get(CharSequence, String) instead.
Returns the value of the "Host" header. If there is no such
header, the defaultValue is returned. |
abstract java.lang.Integer |
getInt(java.lang.CharSequence name)
Returns the integer value of a header with the specified name.
|
abstract int |
getInt(java.lang.CharSequence name,
int defaultValue)
Returns the integer value of a header with the specified name.
|
static int |
getIntHeader(HttpMessage message,
java.lang.CharSequence name)
已过时。
Use
getInt(CharSequence) instead.
Returns the integer header value with the specified header name. If
there are more than one header value for the specified header name, the
first value is returned. |
static int |
getIntHeader(HttpMessage message,
java.lang.CharSequence name,
int defaultValue)
已过时。
Use
getInt(CharSequence, int) instead.
Returns the integer header value with the specified header name. If
there are more than one header value for the specified header name, the
first value is returned. |
static int |
getIntHeader(HttpMessage message,
java.lang.String name)
已过时。
Use
getInt(CharSequence) instead. |
static int |
getIntHeader(HttpMessage message,
java.lang.String name,
int defaultValue)
已过时。
Use
getInt(CharSequence, int) instead. |
abstract java.lang.Short |
getShort(java.lang.CharSequence name)
Returns the short value of a header with the specified name.
|
abstract short |
getShort(java.lang.CharSequence name,
short defaultValue)
Returns the short value of a header with the specified name.
|
abstract java.lang.Long |
getTimeMillis(java.lang.CharSequence name)
Returns the date value of a header with the specified name.
|
abstract long |
getTimeMillis(java.lang.CharSequence name,
long defaultValue)
Returns the date value of a header with the specified name.
|
static boolean |
is100ContinueExpected(HttpMessage message)
已过时。
Use
HttpUtil.is100ContinueExpected(HttpMessage) instead.
Returns true if and only if the specified message contains the
"Expect: 100-continue" header. |
static boolean |
isContentLengthSet(HttpMessage m)
已过时。
Use
HttpUtil.isContentLengthSet(HttpMessage) instead. |
abstract boolean |
isEmpty()
Checks if no header exists.
|
static boolean |
isKeepAlive(HttpMessage message)
已过时。
Use
HttpUtil.isKeepAlive(HttpMessage) instead.
Returns 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(). |
static boolean |
isTransferEncodingChunked(HttpMessage message)
已过时。
Use
HttpUtil.isTransferEncodingChunked(HttpMessage) instead.
Checks to see if the transfer encoding in a specified HttpMessage is chunked |
abstract java.util.Iterator<java.util.Map.Entry<java.lang.String,java.lang.String>> |
iterator()
已过时。
It is preferred to use
iteratorCharSequence() unless you need String.
If String is required then use iteratorAsString(). |
java.util.Iterator<java.util.Map.Entry<java.lang.String,java.lang.String>> |
iteratorAsString()
Iterator that converts each Map.Entry's key and value to a String. |
abstract java.util.Iterator<java.util.Map.Entry<java.lang.CharSequence,java.lang.CharSequence>> |
iteratorCharSequence() |
abstract java.util.Set<java.lang.String> |
names()
Returns a new
Set that contains the names of all headers in this object. |
static java.lang.CharSequence |
newEntity(java.lang.String name)
已过时。
Use
AsciiString instead.
Create a new |
HttpHeaders |
remove(java.lang.CharSequence name)
Removes the header with the specified name.
|
abstract HttpHeaders |
remove(java.lang.String name) |
static void |
removeHeader(HttpMessage message,
java.lang.CharSequence name)
已过时。
Use
remove(CharSequence) instead.
Removes the header with the specified name. |
static void |
removeHeader(HttpMessage message,
java.lang.String name)
已过时。
Use
remove(CharSequence) instead. |
static void |
removeTransferEncodingChunked(HttpMessage m)
已过时。
|
HttpHeaders |
set(java.lang.CharSequence name,
java.lang.Iterable<?> values)
Sets a header with the specified name and values.
|
HttpHeaders |
set(java.lang.CharSequence name,
java.lang.Object value)
Sets a header with the specified name and value.
|
HttpHeaders |
set(HttpHeaders headers)
Cleans the current header entries and copies all header entries of the specified
headers. |
abstract HttpHeaders |
set(java.lang.String name,
java.lang.Iterable<?> values) |
abstract HttpHeaders |
set(java.lang.String name,
java.lang.Object value) |
static void |
set100ContinueExpected(HttpMessage message)
已过时。
Use
HttpUtil.set100ContinueExpected(HttpMessage, boolean) instead.
Sets the "Expect: 100-continue" header to the specified message.
If there is any existing "Expect" header, they are replaced with
the new one. |
static void |
set100ContinueExpected(HttpMessage message,
boolean set)
已过时。
Use
HttpUtil.set100ContinueExpected(HttpMessage, boolean) instead.
Sets or removes the "Expect: 100-continue" header to / from the
specified message. If set is true,
the "Expect: 100-continue" header is set and all other previous
"Expect" headers are removed. Otherwise, all "Expect"
headers are removed completely. |
HttpHeaders |
setAll(HttpHeaders headers)
Retains all current headers but calls
set(String, Object) for each entry in headers |
static void |
setContentLength(HttpMessage message,
long length)
已过时。
Use
HttpUtil.setContentLength(HttpMessage, long) instead. |
static void |
setDate(HttpMessage message,
java.util.Date value)
已过时。
Use
set(CharSequence, Object) instead.
Sets the "Date" header. |
static void |
setDateHeader(HttpMessage message,
java.lang.CharSequence name,
java.util.Date value)
已过时。
Use
set(CharSequence, Object) instead.
Sets a new date header with the specified name and value. If there
is an existing header with the same name, the existing header is removed.
The specified value is formatted as defined in
RFC2616 |
static void |
setDateHeader(HttpMessage message,
java.lang.CharSequence name,
java.lang.Iterable<java.util.Date> values)
已过时。
Use
set(CharSequence, Iterable) instead.
Sets a new date header with the specified name and values. If there
is an existing header with the same name, the existing header is removed.
The specified values are formatted as defined in
RFC2616 |
static void |
setDateHeader(HttpMessage message,
java.lang.String name,
java.util.Date value)
已过时。
Use
set(CharSequence, Object) instead. |
static void |
setDateHeader(HttpMessage message,
java.lang.String name,
java.lang.Iterable<java.util.Date> values)
已过时。
Use
set(CharSequence, Iterable) instead. |
static void |
setHeader(HttpMessage message,
java.lang.CharSequence name,
java.lang.Iterable<?> values)
已过时。
Use
set(CharSequence, Iterable) instead.
Sets a new header with the specified name and values. If there is an
existing header with the same name, the existing header is removed.
This getMethod can be represented approximately as the following code:
removeHeader(message, name);
for (Object v: values) {
if (v == null) {
break;
}
addHeader(message, name, v);
}
|
static void |
setHeader(HttpMessage message,
java.lang.CharSequence name,
java.lang.Object value)
已过时。
Use
set(CharSequence, Object) instead.
Sets a new header with the specified name and value. If there is an
existing header with the same name, the existing header is removed.
If the specified value is not a 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. |
static void |
setHeader(HttpMessage message,
java.lang.String name,
java.lang.Iterable<?> values)
已过时。
Use
set(CharSequence, Iterable) instead. |
static void |
setHeader(HttpMessage message,
java.lang.String name,
java.lang.Object value)
已过时。
Use
set(CharSequence, Object) instead. |
static void |
setHost(HttpMessage message,
java.lang.CharSequence value)
已过时。
Use
set(CharSequence, Object) instead.
Sets the "Host" header. |
static void |
setHost(HttpMessage message,
java.lang.String value)
已过时。
Use
set(CharSequence, Object) instead. |
abstract HttpHeaders |
setInt(java.lang.CharSequence name,
int value)
Set the
name to value. |
static void |
setIntHeader(HttpMessage message,
java.lang.CharSequence name,
int value)
已过时。
Use
setInt(CharSequence, int) instead.
Sets a new integer header with the specified name and value. If there
is an existing header with the same name, the existing header is removed. |
static void |
setIntHeader(HttpMessage message,
java.lang.CharSequence name,
java.lang.Iterable<java.lang.Integer> values)
已过时。
Use
set(CharSequence, Iterable) instead.
Sets a new integer header with the specified name and values. If there
is an existing header with the same name, the existing header is removed. |
static void |
setIntHeader(HttpMessage message,
java.lang.String name,
int value)
已过时。
Use
setInt(CharSequence, int) instead. |
static void |
setIntHeader(HttpMessage message,
java.lang.String name,
java.lang.Iterable<java.lang.Integer> values)
已过时。
Use
set(CharSequence, Iterable) instead. |
static void |
setKeepAlive(HttpMessage message,
boolean keepAlive)
已过时。
Use
HttpUtil.setKeepAlive(HttpMessage, boolean) instead.
Sets the value of the "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().
|
abstract HttpHeaders |
setShort(java.lang.CharSequence name,
short value)
Set the
name to value. |
static void |
setTransferEncodingChunked(HttpMessage m)
已过时。
|
abstract int |
size()
Returns the number of headers in this object.
|
java.lang.String |
toString() |
java.util.Iterator<? extends java.lang.CharSequence> |
valueCharSequenceIterator(java.lang.CharSequence name)
Equivalent to
getAll(String) but it is possible that no intermediate list is generated. |
java.util.Iterator<java.lang.String> |
valueStringIterator(java.lang.CharSequence name)
Equivalent to
getAll(String) but it is possible that no intermediate list is generated. |
@Deprecated public static final HttpHeaders EMPTY_HEADERS
EmptyHttpHeaders.INSTANCE.
The instance is instantiated here to break the cyclic static initialization between EmptyHttpHeaders and
HttpHeaders. The issue is that if someone accesses EmptyHttpHeaders.INSTANCE before
EMPTY_HEADERS then EMPTY_HEADERS will be null.
@Deprecated public static boolean isKeepAlive(HttpMessage message)
HttpUtil.isKeepAlive(HttpMessage) instead.
Returns 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().@Deprecated public static void setKeepAlive(HttpMessage message, boolean keepAlive)
HttpUtil.setKeepAlive(HttpMessage, boolean) instead.
Sets the value of the "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.@Deprecated public static java.lang.String getHeader(HttpMessage message, java.lang.String name)
get(CharSequence) instead.@Deprecated public static java.lang.String getHeader(HttpMessage message, java.lang.CharSequence name)
get(CharSequence) instead.
Returns the header value with the specified header name. If there are
more than one header value for the specified header name, the first
value is returned.null if there is no such header@Deprecated public static java.lang.String getHeader(HttpMessage message, java.lang.String name, java.lang.String defaultValue)
get(CharSequence, String) instead.@Deprecated public static java.lang.String getHeader(HttpMessage message, java.lang.CharSequence name, java.lang.String defaultValue)
get(CharSequence, String) instead.
Returns the header value with the specified header name. If there are
more than one header value for the specified header name, the first
value is returned.defaultValue if there is no such
header@Deprecated public static void setHeader(HttpMessage message, java.lang.String name, java.lang.Object value)
set(CharSequence, Object) instead.@Deprecated public static void setHeader(HttpMessage message, java.lang.CharSequence name, java.lang.Object value)
set(CharSequence, Object) instead.
Sets a new header with the specified name and value. If there is an
existing header with the same name, the existing header is removed.
If the specified value is not a 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.@Deprecated public static void setHeader(HttpMessage message, java.lang.String name, java.lang.Iterable<?> values)
set(CharSequence, Iterable) instead.@Deprecated public static void setHeader(HttpMessage message, java.lang.CharSequence name, java.lang.Iterable<?> values)
set(CharSequence, Iterable) instead.
Sets a new header with the specified name and values. If there is an
existing header with the same name, the existing header is removed.
This getMethod can be represented approximately as the following code:
removeHeader(message, name);
for (Object v: values) {
if (v == null) {
break;
}
addHeader(message, name, v);
}
@Deprecated public static void addHeader(HttpMessage message, java.lang.String name, java.lang.Object value)
add(CharSequence, Object) instead.@Deprecated public static void addHeader(HttpMessage message, java.lang.CharSequence name, java.lang.Object value)
add(CharSequence, Object) instead.
Adds a new header with the specified name and value.
If the specified value is not a 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.@Deprecated public static void removeHeader(HttpMessage message, java.lang.String name)
remove(CharSequence) instead.@Deprecated public static void removeHeader(HttpMessage message, java.lang.CharSequence name)
remove(CharSequence) instead.
Removes the header with the specified name.@Deprecated public static void clearHeaders(HttpMessage message)
clear() instead.
Removes all headers from the specified message.@Deprecated public static int getIntHeader(HttpMessage message, java.lang.String name)
getInt(CharSequence) instead.@Deprecated public static int getIntHeader(HttpMessage message, java.lang.CharSequence name)
getInt(CharSequence) instead.
Returns the integer header value with the specified header name. If
there are more than one header value for the specified header name, the
first value is returned.java.lang.NumberFormatException - if there is no such header or the header value is not a number@Deprecated public static int getIntHeader(HttpMessage message, java.lang.String name, int defaultValue)
getInt(CharSequence, int) instead.@Deprecated public static int getIntHeader(HttpMessage message, java.lang.CharSequence name, int defaultValue)
getInt(CharSequence, int) instead.
Returns the integer header value with the specified header name. If
there are more than one header value for the specified header name, the
first value is returned.defaultValue if there is no such
header or the header value is not a number@Deprecated public static void setIntHeader(HttpMessage message, java.lang.String name, int value)
setInt(CharSequence, int) instead.@Deprecated public static void setIntHeader(HttpMessage message, java.lang.CharSequence name, int value)
setInt(CharSequence, int) instead.
Sets a new integer header with the specified name and value. If there
is an existing header with the same name, the existing header is removed.@Deprecated public static void setIntHeader(HttpMessage message, java.lang.String name, java.lang.Iterable<java.lang.Integer> values)
set(CharSequence, Iterable) instead.@Deprecated public static void setIntHeader(HttpMessage message, java.lang.CharSequence name, java.lang.Iterable<java.lang.Integer> values)
set(CharSequence, Iterable) instead.
Sets a new integer header with the specified name and values. If there
is an existing header with the same name, the existing header is removed.@Deprecated public static void addIntHeader(HttpMessage message, java.lang.String name, int value)
add(CharSequence, Iterable) instead.@Deprecated public static void addIntHeader(HttpMessage message, java.lang.CharSequence name, int value)
addInt(CharSequence, int) instead.
Adds a new integer header with the specified name and value.@Deprecated public static java.util.Date getDateHeader(HttpMessage message, java.lang.String name) throws java.text.ParseException
getTimeMillis(CharSequence) instead.java.text.ParseExceptiongetDateHeader(HttpMessage, CharSequence)@Deprecated public static java.util.Date getDateHeader(HttpMessage message, java.lang.CharSequence name) throws java.text.ParseException
getTimeMillis(CharSequence) instead.
Returns the date header value with the specified header name. If
there are more than one header value for the specified header name, the
first value is returned.java.text.ParseException - if there is no such header or the header value is not a formatted date@Deprecated public static java.util.Date getDateHeader(HttpMessage message, java.lang.String name, java.util.Date defaultValue)
getTimeMillis(CharSequence, long) instead.@Deprecated public static java.util.Date getDateHeader(HttpMessage message, java.lang.CharSequence name, java.util.Date defaultValue)
getTimeMillis(CharSequence, long) instead.
Returns the date header value with the specified header name. If
there are more than one header value for the specified header name, the
first value is returned.defaultValue if there is no such
header or the header value is not a formatted date@Deprecated public static void setDateHeader(HttpMessage message, java.lang.String name, java.util.Date value)
set(CharSequence, Object) instead.@Deprecated public static void setDateHeader(HttpMessage message, java.lang.CharSequence name, java.util.Date value)
set(CharSequence, Object) instead.
Sets a new date header with the specified name and value. If there
is an existing header with the same name, the existing header is removed.
The specified value is formatted as defined in
RFC2616@Deprecated public static void setDateHeader(HttpMessage message, java.lang.String name, java.lang.Iterable<java.util.Date> values)
set(CharSequence, Iterable) instead.@Deprecated public static void setDateHeader(HttpMessage message, java.lang.CharSequence name, java.lang.Iterable<java.util.Date> values)
set(CharSequence, Iterable) instead.
Sets a new date header with the specified name and values. If there
is an existing header with the same name, the existing header is removed.
The specified values are formatted as defined in
RFC2616@Deprecated public static void addDateHeader(HttpMessage message, java.lang.String name, java.util.Date value)
add(CharSequence, Object) instead.@Deprecated public static void addDateHeader(HttpMessage message, java.lang.CharSequence name, java.util.Date value)
add(CharSequence, Object) instead.
Adds a new date header with the specified name and value. The specified
value is formatted as defined in
RFC2616@Deprecated public static long getContentLength(HttpMessage message)
HttpUtil.getContentLength(HttpMessage) instead.
Returns the length of the content. Please note that this value is
not retrieved from ByteBufHolder.content() but from the
"Content-Length" header, and thus they are independent from each
other.java.lang.NumberFormatException - if the message does not have the "Content-Length" header
or its value is not a number@Deprecated public static long getContentLength(HttpMessage message, long defaultValue)
HttpUtil.getContentLength(HttpMessage, long) instead.
Returns the length of the content. Please note that this value is
not retrieved from 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 number@Deprecated public static void setContentLength(HttpMessage message, long length)
HttpUtil.setContentLength(HttpMessage, long) instead.@Deprecated public static java.lang.String getHost(HttpMessage message)
get(CharSequence) instead.
Returns the value of the "Host" header.@Deprecated public static java.lang.String getHost(HttpMessage message, java.lang.String defaultValue)
get(CharSequence, String) instead.
Returns the value of the "Host" header. If there is no such
header, the defaultValue is returned.@Deprecated public static void setHost(HttpMessage message, java.lang.String value)
set(CharSequence, Object) instead.@Deprecated public static void setHost(HttpMessage message, java.lang.CharSequence value)
set(CharSequence, Object) instead.
Sets the "Host" header.@Deprecated public static java.util.Date getDate(HttpMessage message) throws java.text.ParseException
getTimeMillis(CharSequence) instead.
Returns the value of the "Date" header.java.text.ParseException - if there is no such header or the header value is not a formatted date@Deprecated public static java.util.Date getDate(HttpMessage message, java.util.Date defaultValue)
getTimeMillis(CharSequence, long) instead.
Returns the value of the "Date" header. If there is no such
header or the header is not a formatted date, the defaultValue
is returned.@Deprecated public static void setDate(HttpMessage message, java.util.Date value)
set(CharSequence, Object) instead.
Sets the "Date" header.@Deprecated public static boolean is100ContinueExpected(HttpMessage message)
HttpUtil.is100ContinueExpected(HttpMessage) instead.
Returns true if and only if the specified message contains the
"Expect: 100-continue" header.@Deprecated public static void set100ContinueExpected(HttpMessage message)
HttpUtil.set100ContinueExpected(HttpMessage, boolean) instead.
Sets the "Expect: 100-continue" header to the specified message.
If there is any existing "Expect" header, they are replaced with
the new one.@Deprecated public static void set100ContinueExpected(HttpMessage message, boolean set)
HttpUtil.set100ContinueExpected(HttpMessage, boolean) instead.
Sets or removes the "Expect: 100-continue" header to / from the
specified message. If set is true,
the "Expect: 100-continue" header is set and all other previous
"Expect" headers are removed. Otherwise, all "Expect"
headers are removed completely.@Deprecated public static boolean isTransferEncodingChunked(HttpMessage message)
HttpUtil.isTransferEncodingChunked(HttpMessage) instead.
Checks to see if the transfer encoding in a specified HttpMessage is chunkedmessage - The message to check@Deprecated public static void removeTransferEncodingChunked(HttpMessage m)
HttpUtil.setTransferEncodingChunked(HttpMessage, boolean) instead.@Deprecated public static void setTransferEncodingChunked(HttpMessage m)
HttpUtil.setTransferEncodingChunked(HttpMessage, boolean) instead.@Deprecated public static boolean isContentLengthSet(HttpMessage m)
HttpUtil.isContentLengthSet(HttpMessage) instead.@Deprecated
public static boolean equalsIgnoreCase(java.lang.CharSequence name1,
java.lang.CharSequence name2)
AsciiString.contentEqualsIgnoreCase(CharSequence, CharSequence) instead.@Deprecated
public static void encodeAscii(java.lang.CharSequence seq,
ByteBuf buf)
@Deprecated public static java.lang.CharSequence newEntity(java.lang.String name)
AsciiString instead.
Create a new CharSequence which is optimized for reuse as HttpHeaders name or value.
So if you have a Header name or value that you want to reuse you should make use of this.
public abstract java.lang.String get(java.lang.String name)
get(CharSequence)public java.lang.String get(java.lang.CharSequence name)
name - The name of the header to searchnull if there is no such headergetAsString(CharSequence)public java.lang.String get(java.lang.CharSequence name,
java.lang.String defaultValue)
name - The name of the header to searchdefaultValue if there is no such headerpublic abstract java.lang.Integer getInt(java.lang.CharSequence name)
name - the name of the header to searchnull if there's no
such header or its value is not an integer.public abstract int getInt(java.lang.CharSequence name,
int defaultValue)
name - the name of the header to searchdefaultValue - the default valuedefaultValue if
there's no such header or its value is not an integer.public abstract java.lang.Short getShort(java.lang.CharSequence name)
name - the name of the header to searchnull if there's no
such header or its value is not a short.public abstract short getShort(java.lang.CharSequence name,
short defaultValue)
name - the name of the header to searchdefaultValue - the default valuedefaultValue if
there's no such header or its value is not a short.public abstract java.lang.Long getTimeMillis(java.lang.CharSequence name)
name - the name of the header to searchnull if there's no
such header or its value is not a date.public abstract long getTimeMillis(java.lang.CharSequence name,
long defaultValue)
name - the name of the header to searchdefaultValue - the default valuedefaultValue if
there's no such header or its value is not a date.public abstract java.util.List<java.lang.String> getAll(java.lang.String name)
getAll(CharSequence)public java.util.List<java.lang.String> getAll(java.lang.CharSequence name)
name - The name of the headers to searchList of header values which will be empty if no values
are foundgetAllAsString(CharSequence)public abstract java.util.List<java.util.Map.Entry<java.lang.String,java.lang.String>> entries()
List that contains all headers in this object. Note that modifying the
returned List will not affect the state of this object. If you intend to enumerate over the header
entries only, use iterator() instead, which has much less overhead.iteratorCharSequence()public abstract boolean contains(java.lang.String name)
contains(CharSequence)@Deprecated public abstract java.util.Iterator<java.util.Map.Entry<java.lang.String,java.lang.String>> iterator()
iteratorCharSequence() unless you need String.
If String is required then use iteratorAsString().iterator 在接口中 java.lang.Iterable<java.util.Map.Entry<java.lang.String,java.lang.String>>public abstract java.util.Iterator<java.util.Map.Entry<java.lang.CharSequence,java.lang.CharSequence>> iteratorCharSequence()
public java.util.Iterator<java.lang.String> valueStringIterator(java.lang.CharSequence name)
getAll(String) but it is possible that no intermediate list is generated.name - the name of the header to retrieveIterator of header values corresponding to name.public java.util.Iterator<? extends java.lang.CharSequence> valueCharSequenceIterator(java.lang.CharSequence name)
getAll(String) but it is possible that no intermediate list is generated.name - the name of the header to retrieveIterator of header values corresponding to name.public boolean contains(java.lang.CharSequence name)
name - The name of the header to search forpublic abstract boolean isEmpty()
public abstract int size()
public abstract java.util.Set<java.lang.String> names()
Set that contains the names of all headers in this object. Note that modifying the
returned Set will not affect the state of this object. If you intend to enumerate over the header
entries only, use iterator() instead, which has much less overhead.public abstract HttpHeaders add(java.lang.String name, java.lang.Object value)
public HttpHeaders add(java.lang.CharSequence name, java.lang.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 addedthispublic abstract HttpHeaders add(java.lang.String name, java.lang.Iterable<?> values)
public HttpHeaders add(java.lang.CharSequence name, java.lang.Iterable<?> values)
for (Object v: values) {
if (v == null) {
break;
}
headers.add(name, v);
}
name - The name of the headers being setvalues - The values of the headers being setthispublic HttpHeaders add(HttpHeaders headers)
headers.thispublic abstract HttpHeaders addInt(java.lang.CharSequence name, int value)
name to value.name - The name to modifyvalue - The valuethispublic abstract HttpHeaders addShort(java.lang.CharSequence name, short value)
name to value.name - The name to modifyvalue - The valuethispublic abstract HttpHeaders set(java.lang.String name, java.lang.Object value)
public HttpHeaders set(java.lang.CharSequence name, java.lang.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 setthispublic abstract HttpHeaders set(java.lang.String name, java.lang.Iterable<?> values)
public HttpHeaders set(java.lang.CharSequence name, java.lang.Iterable<?> values)
headers.remove(name);
for (Object v: values) {
if (v == null) {
break;
}
headers.add(name, v);
}
name - The name of the headers being setvalues - The values of the headers being setthispublic HttpHeaders set(HttpHeaders headers)
headers.thispublic HttpHeaders setAll(HttpHeaders headers)
set(String, Object) for each entry in headersheaders - The headers used to set(String, Object) values in this instancethispublic abstract HttpHeaders setInt(java.lang.CharSequence name, int value)
name to value. This will remove all previous values associated with name.name - The name to modifyvalue - The valuethispublic abstract HttpHeaders setShort(java.lang.CharSequence name, short value)
name to value. This will remove all previous values associated with name.name - The name to modifyvalue - The valuethispublic abstract HttpHeaders remove(java.lang.String name)
remove(CharSequence)public HttpHeaders remove(java.lang.CharSequence name)
name - The name of the header to removethispublic abstract HttpHeaders clear()
HttpMessage.thispublic boolean contains(java.lang.String name,
java.lang.String value,
boolean ignoreCase)
public boolean containsValue(java.lang.CharSequence name,
java.lang.CharSequence value,
boolean ignoreCase)
true if a header with the name and value exists, false otherwise.
This also handles multiple values that are separated with a ,.
If ignoreCase is true then a case insensitive compare is done on the value.
name - the name of the header to findvalue - the value of the header to findignoreCase - true then a case insensitive compare is run to compare values.
otherwise a case sensitive compare is run to compare values.public final java.lang.String getAsString(java.lang.CharSequence name)
Headers.get(Object) and convert the result to a String.name - the name of the header to retrievenull if there's no such header.public final java.util.List<java.lang.String> getAllAsString(java.lang.CharSequence name)
name - the name of the header to retrieveList of header values or an empty List if no values are found.public final java.util.Iterator<java.util.Map.Entry<java.lang.String,java.lang.String>> iteratorAsString()
Iterator that converts each Map.Entry's key and value to a String.public boolean contains(java.lang.CharSequence name,
java.lang.CharSequence value,
boolean ignoreCase)
true if a header with the name and value exists, false otherwise.
If ignoreCase is true then a case insensitive compare is done on the value.
name - the name of the header to findvalue - the value of the header to findignoreCase - true then a case insensitive compare is run to compare values.
otherwise a case sensitive compare is run to compare values.public java.lang.String toString()
toString 在类中 java.lang.Objectpublic HttpHeaders copy()
HttpHeaders.