Package io.netty.handler.codec.http
Class HttpHeaders
- java.lang.Object
-
- io.netty.handler.codec.http.HttpHeaders
-
- All Implemented Interfaces:
java.lang.Iterable<java.util.Map.Entry<java.lang.String,java.lang.String>>
- Direct Known Subclasses:
DefaultHttpHeaders,EmptyHttpHeaders,ReadOnlyHttpHeaders
public abstract class HttpHeaders extends java.lang.Object implements java.lang.Iterable<java.util.Map.Entry<java.lang.String,java.lang.String>>Provides the constants for the standard HTTP header names and values and commonly used utility methods that accesses anHttpMessage.Concrete instances of this class are most easily obtained from its default factory:
DefaultHttpHeadersFactory.headersFactory().
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classHttpHeaders.NamesDeprecated.UseHttpHeaderNamesinstead.static classHttpHeaders.ValuesDeprecated.UseHttpHeaderValuesinstead.
-
Field Summary
Fields Modifier and Type Field Description static HttpHeadersEMPTY_HEADERSDeprecated.
-
Constructor Summary
Constructors Modifier Constructor Description protectedHttpHeaders()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description HttpHeadersadd(HttpHeaders headers)Adds all header entries of the specifiedheaders.HttpHeadersadd(java.lang.CharSequence name, java.lang.Iterable<?> values)Adds a new header with the specified name and values.HttpHeadersadd(java.lang.CharSequence name, java.lang.Object value)Adds a new header with the specified name and value.abstract HttpHeadersadd(java.lang.String name, java.lang.Iterable<?> values)abstract HttpHeadersadd(java.lang.String name, java.lang.Object value)static voidaddDateHeader(HttpMessage message, java.lang.CharSequence name, java.util.Date value)Deprecated.Useadd(CharSequence, Object)instead.static voidaddDateHeader(HttpMessage message, java.lang.String name, java.util.Date value)Deprecated.Useadd(CharSequence, Object)instead.static voidaddHeader(HttpMessage message, java.lang.CharSequence name, java.lang.Object value)Deprecated.Useadd(CharSequence, Object)instead.static voidaddHeader(HttpMessage message, java.lang.String name, java.lang.Object value)Deprecated.Useadd(CharSequence, Object)instead.abstract HttpHeadersaddInt(java.lang.CharSequence name, int value)Add thenametovalue.static voidaddIntHeader(HttpMessage message, java.lang.CharSequence name, int value)Deprecated.UseaddInt(CharSequence, int)instead.static voidaddIntHeader(HttpMessage message, java.lang.String name, int value)Deprecated.Useadd(CharSequence, Iterable)instead.abstract HttpHeadersaddShort(java.lang.CharSequence name, short value)Add thenametovalue.abstract HttpHeadersclear()Removes all headers from thisHttpMessage.static voidclearHeaders(HttpMessage message)Deprecated.Useclear()instead.booleancontains(java.lang.CharSequence name)Checks to see if there is a header with the specified namebooleancontains(java.lang.CharSequence name, java.lang.CharSequence value, boolean ignoreCase)Returnstrueif a header with thenameandvalueexists,falseotherwise.abstract booleancontains(java.lang.String name)booleancontains(java.lang.String name, java.lang.String value, boolean ignoreCase)booleancontainsValue(java.lang.CharSequence name, java.lang.CharSequence value, boolean ignoreCase)Returnstrueif a header with thenameandvalueexists,falseotherwise.HttpHeaderscopy()Returns a deep copy of the passed inHttpHeaders.static voidencodeAscii(java.lang.CharSequence seq, ByteBuf buf)Deprecated.abstract java.util.List<java.util.Map.Entry<java.lang.String,java.lang.String>>entries()Returns a newListthat contains all headers in this object.static booleanequalsIgnoreCase(java.lang.CharSequence name1, java.lang.CharSequence name2)Deprecated.java.lang.Stringget(java.lang.CharSequence name)Returns the value of a header with the specified name.java.lang.Stringget(java.lang.CharSequence name, java.lang.String defaultValue)Returns the value of a header with the specified name.abstract java.lang.Stringget(java.lang.String name)java.util.List<java.lang.String>getAll(java.lang.CharSequence name)Returns the values of headers with the specified nameabstract java.util.List<java.lang.String>getAll(java.lang.String name)java.util.List<java.lang.String>getAllAsString(java.lang.CharSequence name)java.lang.StringgetAsString(java.lang.CharSequence name)Headers.get(Object)and convert the result to aString.static longgetContentLength(HttpMessage message)Deprecated.UseHttpUtil.getContentLength(HttpMessage)instead.static longgetContentLength(HttpMessage message, long defaultValue)Deprecated.UseHttpUtil.getContentLength(HttpMessage, long)instead.static java.util.DategetDate(HttpMessage message)Deprecated.UsegetTimeMillis(CharSequence)instead.static java.util.DategetDate(HttpMessage message, java.util.Date defaultValue)Deprecated.UsegetTimeMillis(CharSequence, long)instead.static java.util.DategetDateHeader(HttpMessage message, java.lang.CharSequence name)Deprecated.UsegetTimeMillis(CharSequence)instead.static java.util.DategetDateHeader(HttpMessage message, java.lang.CharSequence name, java.util.Date defaultValue)Deprecated.UsegetTimeMillis(CharSequence, long)instead.static java.util.DategetDateHeader(HttpMessage message, java.lang.String name)Deprecated.UsegetTimeMillis(CharSequence)instead.static java.util.DategetDateHeader(HttpMessage message, java.lang.String name, java.util.Date defaultValue)Deprecated.UsegetTimeMillis(CharSequence, long)instead.static java.lang.StringgetHeader(HttpMessage message, java.lang.CharSequence name)Deprecated.Useget(CharSequence)instead.static java.lang.StringgetHeader(HttpMessage message, java.lang.CharSequence name, java.lang.String defaultValue)Deprecated.Useget(CharSequence, String)instead.static java.lang.StringgetHeader(HttpMessage message, java.lang.String name)Deprecated.Useget(CharSequence)instead.static java.lang.StringgetHeader(HttpMessage message, java.lang.String name, java.lang.String defaultValue)Deprecated.Useget(CharSequence, String)instead.static java.lang.StringgetHost(HttpMessage message)Deprecated.Useget(CharSequence)instead.static java.lang.StringgetHost(HttpMessage message, java.lang.String defaultValue)Deprecated.Useget(CharSequence, String)instead.abstract java.lang.IntegergetInt(java.lang.CharSequence name)Returns the integer value of a header with the specified name.abstract intgetInt(java.lang.CharSequence name, int defaultValue)Returns the integer value of a header with the specified name.static intgetIntHeader(HttpMessage message, java.lang.CharSequence name)Deprecated.UsegetInt(CharSequence)instead.static intgetIntHeader(HttpMessage message, java.lang.CharSequence name, int defaultValue)Deprecated.UsegetInt(CharSequence, int)instead.static intgetIntHeader(HttpMessage message, java.lang.String name)Deprecated.UsegetInt(CharSequence)instead.static intgetIntHeader(HttpMessage message, java.lang.String name, int defaultValue)Deprecated.UsegetInt(CharSequence, int)instead.abstract java.lang.ShortgetShort(java.lang.CharSequence name)Returns the short value of a header with the specified name.abstract shortgetShort(java.lang.CharSequence name, short defaultValue)Returns the short value of a header with the specified name.abstract java.lang.LonggetTimeMillis(java.lang.CharSequence name)Returns the date value of a header with the specified name.abstract longgetTimeMillis(java.lang.CharSequence name, long defaultValue)Returns the date value of a header with the specified name.static booleanis100ContinueExpected(HttpMessage message)Deprecated.UseHttpUtil.is100ContinueExpected(HttpMessage)instead.static booleanisContentLengthSet(HttpMessage m)Deprecated.UseHttpUtil.isContentLengthSet(HttpMessage)instead.abstract booleanisEmpty()Checks if no header exists.static booleanisKeepAlive(HttpMessage message)Deprecated.UseHttpUtil.isKeepAlive(HttpMessage)instead.static booleanisTransferEncodingChunked(HttpMessage message)Deprecated.UseHttpUtil.isTransferEncodingChunked(HttpMessage)instead.abstract java.util.Iterator<java.util.Map.Entry<java.lang.String,java.lang.String>>iterator()Deprecated.It is preferred to useiteratorCharSequence()unless you needString.java.util.Iterator<java.util.Map.Entry<java.lang.String,java.lang.String>>iteratorAsString()Iteratorthat converts eachMap.Entry's key and value to aString.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 newSetthat contains the names of all headers in this object.static java.lang.CharSequencenewEntity(java.lang.String name)Deprecated.UseAsciiStringinstead.HttpHeadersremove(java.lang.CharSequence name)Removes the header with the specified name.abstract HttpHeadersremove(java.lang.String name)static voidremoveHeader(HttpMessage message, java.lang.CharSequence name)Deprecated.Useremove(CharSequence)instead.static voidremoveHeader(HttpMessage message, java.lang.String name)Deprecated.Useremove(CharSequence)instead.static voidremoveTransferEncodingChunked(HttpMessage m)Deprecated.HttpHeadersset(HttpHeaders headers)Cleans the current header entries and copies all header entries of the specifiedheaders.HttpHeadersset(java.lang.CharSequence name, java.lang.Iterable<?> values)Sets a header with the specified name and values.HttpHeadersset(java.lang.CharSequence name, java.lang.Object value)Sets a header with the specified name and value.abstract HttpHeadersset(java.lang.String name, java.lang.Iterable<?> values)abstract HttpHeadersset(java.lang.String name, java.lang.Object value)static voidset100ContinueExpected(HttpMessage message)Deprecated.static voidset100ContinueExpected(HttpMessage message, boolean set)Deprecated.HttpHeaderssetAll(HttpHeaders headers)Retains all current headers but callsset(String, Object)for each entry inheadersstatic voidsetContentLength(HttpMessage message, long length)Deprecated.UseHttpUtil.setContentLength(HttpMessage, long)instead.static voidsetDate(HttpMessage message, java.util.Date value)Deprecated.Useset(CharSequence, Object)instead.static voidsetDateHeader(HttpMessage message, java.lang.CharSequence name, java.lang.Iterable<java.util.Date> values)Deprecated.Useset(CharSequence, Iterable)instead.static voidsetDateHeader(HttpMessage message, java.lang.CharSequence name, java.util.Date value)Deprecated.Useset(CharSequence, Object)instead.static voidsetDateHeader(HttpMessage message, java.lang.String name, java.lang.Iterable<java.util.Date> values)Deprecated.Useset(CharSequence, Iterable)instead.static voidsetDateHeader(HttpMessage message, java.lang.String name, java.util.Date value)Deprecated.Useset(CharSequence, Object)instead.static voidsetHeader(HttpMessage message, java.lang.CharSequence name, java.lang.Iterable<?> values)Deprecated.Useset(CharSequence, Iterable)instead.static voidsetHeader(HttpMessage message, java.lang.CharSequence name, java.lang.Object value)Deprecated.Useset(CharSequence, Object)instead.static voidsetHeader(HttpMessage message, java.lang.String name, java.lang.Iterable<?> values)Deprecated.Useset(CharSequence, Iterable)instead.static voidsetHeader(HttpMessage message, java.lang.String name, java.lang.Object value)Deprecated.Useset(CharSequence, Object)instead.static voidsetHost(HttpMessage message, java.lang.CharSequence value)Deprecated.Useset(CharSequence, Object)instead.static voidsetHost(HttpMessage message, java.lang.String value)Deprecated.Useset(CharSequence, Object)instead.abstract HttpHeaderssetInt(java.lang.CharSequence name, int value)Set thenametovalue.static voidsetIntHeader(HttpMessage message, java.lang.CharSequence name, int value)Deprecated.UsesetInt(CharSequence, int)instead.static voidsetIntHeader(HttpMessage message, java.lang.CharSequence name, java.lang.Iterable<java.lang.Integer> values)Deprecated.Useset(CharSequence, Iterable)instead.static voidsetIntHeader(HttpMessage message, java.lang.String name, int value)Deprecated.UsesetInt(CharSequence, int)instead.static voidsetIntHeader(HttpMessage message, java.lang.String name, java.lang.Iterable<java.lang.Integer> values)Deprecated.Useset(CharSequence, Iterable)instead.static voidsetKeepAlive(HttpMessage message, boolean keepAlive)Deprecated.UseHttpUtil.setKeepAlive(HttpMessage, boolean)instead.abstract HttpHeaderssetShort(java.lang.CharSequence name, short value)Set thenametovalue.static voidsetTransferEncodingChunked(HttpMessage m)Deprecated.abstract intsize()Returns the number of headers in this object.java.lang.StringtoString()java.util.Iterator<? extends java.lang.CharSequence>valueCharSequenceIterator(java.lang.CharSequence name)Equivalent togetAll(String)but it is possible that no intermediate list is generated.java.util.Iterator<java.lang.String>valueStringIterator(java.lang.CharSequence name)Equivalent togetAll(String)but it is possible that no intermediate list is generated.
-
-
-
Field Detail
-
EMPTY_HEADERS
@Deprecated public static final HttpHeaders EMPTY_HEADERS
Deprecated.UseEmptyHttpHeaders.INSTANCE.The instance is instantiated here to break the cyclic static initialization between
EmptyHttpHeadersandHttpHeaders. The issue is that if someone accessesEmptyHttpHeaders.INSTANCEbeforeEMPTY_HEADERSthenEMPTY_HEADERSwill benull.
-
-
Method Detail
-
isKeepAlive
@Deprecated public static boolean isKeepAlive(HttpMessage message)
Deprecated.UseHttpUtil.isKeepAlive(HttpMessage)instead. Returnstrueif 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 ofHttpVersion.isKeepAliveDefault().
-
setKeepAlive
@Deprecated public static void setKeepAlive(HttpMessage message, boolean keepAlive)
Deprecated.UseHttpUtil.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 byHttpVersion.isKeepAliveDefault().- If the connection is kept alive by default:
- set to
"close"ifkeepAliveisfalse. - remove otherwise.
- set to
- If the connection is closed by default:
- set to
"keep-alive"ifkeepAliveistrue. - remove otherwise.
- set to
- If the connection is kept alive by default:
-
getHeader
@Deprecated public static java.lang.String getHeader(HttpMessage message, java.lang.String name)
Deprecated.Useget(CharSequence)instead.
-
getHeader
@Deprecated public static java.lang.String getHeader(HttpMessage message, java.lang.CharSequence name)
Deprecated.Useget(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.- Returns:
- the header value or
nullif there is no such header
-
getHeader
@Deprecated public static java.lang.String getHeader(HttpMessage message, java.lang.String name, java.lang.String defaultValue)
Deprecated.Useget(CharSequence, String)instead.
-
getHeader
@Deprecated public static java.lang.String getHeader(HttpMessage message, java.lang.CharSequence name, java.lang.String defaultValue)
Deprecated.Useget(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.- Returns:
- the header value or the
defaultValueif there is no such header
-
setHeader
@Deprecated public static void setHeader(HttpMessage message, java.lang.String name, java.lang.Object value)
Deprecated.Useset(CharSequence, Object)instead.
-
setHeader
@Deprecated public static void setHeader(HttpMessage message, java.lang.CharSequence name, java.lang.Object value)
Deprecated.Useset(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 aString, it is converted into aStringbyObject.toString(), except forDateandCalendarwhich are formatted to the date format defined in RFC2616.
-
setHeader
@Deprecated public static void setHeader(HttpMessage message, java.lang.String name, java.lang.Iterable<?> values)
Deprecated.Useset(CharSequence, Iterable)instead.
-
setHeader
@Deprecated public static void setHeader(HttpMessage message, java.lang.CharSequence name, java.lang.Iterable<?> values)
Deprecated.Useset(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); }
-
addHeader
@Deprecated public static void addHeader(HttpMessage message, java.lang.String name, java.lang.Object value)
Deprecated.Useadd(CharSequence, Object)instead.
-
addHeader
@Deprecated public static void addHeader(HttpMessage message, java.lang.CharSequence name, java.lang.Object value)
Deprecated.Useadd(CharSequence, Object)instead. Adds a new header with the specified name and value. If the specified value is not aString, it is converted into aStringbyObject.toString(), except forDateandCalendarwhich are formatted to the date format defined in RFC2616.
-
removeHeader
@Deprecated public static void removeHeader(HttpMessage message, java.lang.String name)
Deprecated.Useremove(CharSequence)instead.- See Also:
removeHeader(HttpMessage, CharSequence)
-
removeHeader
@Deprecated public static void removeHeader(HttpMessage message, java.lang.CharSequence name)
Deprecated.Useremove(CharSequence)instead. Removes the header with the specified name.
-
clearHeaders
@Deprecated public static void clearHeaders(HttpMessage message)
Deprecated.Useclear()instead. Removes all headers from the specified message.
-
getIntHeader
@Deprecated public static int getIntHeader(HttpMessage message, java.lang.String name)
Deprecated.UsegetInt(CharSequence)instead.- See Also:
getIntHeader(HttpMessage, CharSequence)
-
getIntHeader
@Deprecated public static int getIntHeader(HttpMessage message, java.lang.CharSequence name)
Deprecated.UsegetInt(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.- Returns:
- the header value
- Throws:
java.lang.NumberFormatException- if there is no such header or the header value is not a number
-
getIntHeader
@Deprecated public static int getIntHeader(HttpMessage message, java.lang.String name, int defaultValue)
Deprecated.UsegetInt(CharSequence, int)instead.
-
getIntHeader
@Deprecated public static int getIntHeader(HttpMessage message, java.lang.CharSequence name, int defaultValue)
Deprecated.UsegetInt(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.- Returns:
- the header value or the
defaultValueif there is no such header or the header value is not a number
-
setIntHeader
@Deprecated public static void setIntHeader(HttpMessage message, java.lang.String name, int value)
Deprecated.UsesetInt(CharSequence, int)instead.
-
setIntHeader
@Deprecated public static void setIntHeader(HttpMessage message, java.lang.CharSequence name, int value)
Deprecated.UsesetInt(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.
-
setIntHeader
@Deprecated public static void setIntHeader(HttpMessage message, java.lang.String name, java.lang.Iterable<java.lang.Integer> values)
Deprecated.Useset(CharSequence, Iterable)instead.
-
setIntHeader
@Deprecated public static void setIntHeader(HttpMessage message, java.lang.CharSequence name, java.lang.Iterable<java.lang.Integer> values)
Deprecated.Useset(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.
-
addIntHeader
@Deprecated public static void addIntHeader(HttpMessage message, java.lang.String name, int value)
Deprecated.Useadd(CharSequence, Iterable)instead.
-
addIntHeader
@Deprecated public static void addIntHeader(HttpMessage message, java.lang.CharSequence name, int value)
Deprecated.UseaddInt(CharSequence, int)instead. Adds a new integer header with the specified name and value.
-
getDateHeader
@Deprecated public static java.util.Date getDateHeader(HttpMessage message, java.lang.String name) throws java.text.ParseException
Deprecated.UsegetTimeMillis(CharSequence)instead.- Throws:
java.text.ParseException- See Also:
getDateHeader(HttpMessage, CharSequence)
-
getDateHeader
@Deprecated public static java.util.Date getDateHeader(HttpMessage message, java.lang.CharSequence name) throws java.text.ParseException
Deprecated.UsegetTimeMillis(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.- Returns:
- the header value
- Throws:
java.text.ParseException- if there is no such header or the header value is not a formatted date
-
getDateHeader
@Deprecated public static java.util.Date getDateHeader(HttpMessage message, java.lang.String name, java.util.Date defaultValue)
Deprecated.UsegetTimeMillis(CharSequence, long)instead.
-
getDateHeader
@Deprecated public static java.util.Date getDateHeader(HttpMessage message, java.lang.CharSequence name, java.util.Date defaultValue)
Deprecated.UsegetTimeMillis(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.- Returns:
- the header value or the
defaultValueif there is no such header or the header value is not a formatted date
-
setDateHeader
@Deprecated public static void setDateHeader(HttpMessage message, java.lang.String name, java.util.Date value)
Deprecated.Useset(CharSequence, Object)instead.
-
setDateHeader
@Deprecated public static void setDateHeader(HttpMessage message, java.lang.CharSequence name, java.util.Date value)
Deprecated.Useset(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
-
setDateHeader
@Deprecated public static void setDateHeader(HttpMessage message, java.lang.String name, java.lang.Iterable<java.util.Date> values)
Deprecated.Useset(CharSequence, Iterable)instead.
-
setDateHeader
@Deprecated public static void setDateHeader(HttpMessage message, java.lang.CharSequence name, java.lang.Iterable<java.util.Date> values)
Deprecated.Useset(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
-
addDateHeader
@Deprecated public static void addDateHeader(HttpMessage message, java.lang.String name, java.util.Date value)
Deprecated.Useadd(CharSequence, Object)instead.
-
addDateHeader
@Deprecated public static void addDateHeader(HttpMessage message, java.lang.CharSequence name, java.util.Date value)
Deprecated.Useadd(CharSequence, Object)instead. Adds a new date header with the specified name and value. The specified value is formatted as defined in RFC2616
-
getContentLength
@Deprecated public static long getContentLength(HttpMessage message)
Deprecated.UseHttpUtil.getContentLength(HttpMessage)instead. Returns the length of the content. Please note that this value is not retrieved fromByteBufHolder.content()but from the"Content-Length"header, and thus they are independent from each other.- Returns:
- the content length
- Throws:
java.lang.NumberFormatException- if the message does not have the"Content-Length"header or its value is not a number
-
getContentLength
@Deprecated public static long getContentLength(HttpMessage message, long defaultValue)
Deprecated.UseHttpUtil.getContentLength(HttpMessage, long)instead. Returns the length of the content. Please note that this value is not retrieved fromByteBufHolder.content()but from the"Content-Length"header, and thus they are independent from each other.- Returns:
- the content length or
defaultValueif this message does not have the"Content-Length"header or its value is not a number
-
setContentLength
@Deprecated public static void setContentLength(HttpMessage message, long length)
Deprecated.UseHttpUtil.setContentLength(HttpMessage, long)instead.
-
getHost
@Deprecated public static java.lang.String getHost(HttpMessage message)
Deprecated.Useget(CharSequence)instead. Returns the value of the"Host"header.
-
getHost
@Deprecated public static java.lang.String getHost(HttpMessage message, java.lang.String defaultValue)
Deprecated.Useget(CharSequence, String)instead. Returns the value of the"Host"header. If there is no such header, thedefaultValueis returned.
-
setHost
@Deprecated public static void setHost(HttpMessage message, java.lang.String value)
Deprecated.Useset(CharSequence, Object)instead.- See Also:
setHost(HttpMessage, CharSequence)
-
setHost
@Deprecated public static void setHost(HttpMessage message, java.lang.CharSequence value)
Deprecated.Useset(CharSequence, Object)instead. Sets the"Host"header.
-
getDate
@Deprecated public static java.util.Date getDate(HttpMessage message) throws java.text.ParseException
Deprecated.UsegetTimeMillis(CharSequence)instead. Returns the value of the"Date"header.- Throws:
java.text.ParseException- if there is no such header or the header value is not a formatted date
-
getDate
@Deprecated public static java.util.Date getDate(HttpMessage message, java.util.Date defaultValue)
Deprecated.UsegetTimeMillis(CharSequence, long)instead. Returns the value of the"Date"header. If there is no such header or the header is not a formatted date, thedefaultValueis returned.
-
setDate
@Deprecated public static void setDate(HttpMessage message, java.util.Date value)
Deprecated.Useset(CharSequence, Object)instead. Sets the"Date"header.
-
is100ContinueExpected
@Deprecated public static boolean is100ContinueExpected(HttpMessage message)
Deprecated.UseHttpUtil.is100ContinueExpected(HttpMessage)instead. Returnstrueif and only if the specified message contains the"Expect: 100-continue"header.
-
set100ContinueExpected
@Deprecated public static void set100ContinueExpected(HttpMessage message)
Deprecated.UseHttpUtil.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.
-
set100ContinueExpected
@Deprecated public static void set100ContinueExpected(HttpMessage message, boolean set)
Deprecated.UseHttpUtil.set100ContinueExpected(HttpMessage, boolean)instead. Sets or removes the"Expect: 100-continue"header to / from the specified message. Ifsetistrue, the"Expect: 100-continue"header is set and all other previous"Expect"headers are removed. Otherwise, all"Expect"headers are removed completely.
-
isTransferEncodingChunked
@Deprecated public static boolean isTransferEncodingChunked(HttpMessage message)
Deprecated.UseHttpUtil.isTransferEncodingChunked(HttpMessage)instead. Checks to see if the transfer encoding in a specifiedHttpMessageis chunked- Parameters:
message- The message to check- Returns:
- True if transfer encoding is chunked, otherwise false
-
removeTransferEncodingChunked
@Deprecated public static void removeTransferEncodingChunked(HttpMessage m)
Deprecated.
-
setTransferEncodingChunked
@Deprecated public static void setTransferEncodingChunked(HttpMessage m)
Deprecated.
-
isContentLengthSet
@Deprecated public static boolean isContentLengthSet(HttpMessage m)
Deprecated.UseHttpUtil.isContentLengthSet(HttpMessage)instead.
-
equalsIgnoreCase
@Deprecated public static boolean equalsIgnoreCase(java.lang.CharSequence name1, java.lang.CharSequence name2)Deprecated.
-
encodeAscii
@Deprecated public static void encodeAscii(java.lang.CharSequence seq, ByteBuf buf)Deprecated.
-
newEntity
@Deprecated public static java.lang.CharSequence newEntity(java.lang.String name)
Deprecated.UseAsciiStringinstead.Create a new
CharSequencewhich is optimized for reuse asHttpHeadersname or value. So if you have a Header name or value that you want to reuse you should make use of this.
-
get
public abstract java.lang.String get(java.lang.String name)
- See Also:
get(CharSequence)
-
get
public java.lang.String get(java.lang.CharSequence name)
Returns the value of a header with the specified name. If there are more than one values for the specified name, the first value is returned.- Parameters:
name- The name of the header to search- Returns:
- The first header value or
nullif there is no such header - See Also:
getAsString(CharSequence)
-
get
public java.lang.String get(java.lang.CharSequence name, java.lang.String defaultValue)Returns the value of a header with the specified name. If there are more than one values for the specified name, the first value is returned.- Parameters:
name- The name of the header to search- Returns:
- The first header value or
defaultValueif there is no such header
-
getInt
public abstract java.lang.Integer getInt(java.lang.CharSequence name)
Returns the integer value of a header with the specified name. If there are more than one values for the specified name, the first value is returned.- Parameters:
name- the name of the header to search- Returns:
- the first header value if the header is found and its value is an integer.
nullif there's no such header or its value is not an integer.
-
getInt
public abstract int getInt(java.lang.CharSequence name, int defaultValue)Returns the integer value of a header with the specified name. If there are more than one values for the specified name, the first value is returned.- Parameters:
name- the name of the header to searchdefaultValue- the default value- Returns:
- the first header value if the header is found and its value is an integer.
defaultValueif there's no such header or its value is not an integer.
-
getShort
public abstract java.lang.Short getShort(java.lang.CharSequence name)
Returns the short value of a header with the specified name. If there are more than one values for the specified name, the first value is returned.- Parameters:
name- the name of the header to search- Returns:
- the first header value if the header is found and its value is a short.
nullif there's no such header or its value is not a short.
-
getShort
public abstract short getShort(java.lang.CharSequence name, short defaultValue)Returns the short value of a header with the specified name. If there are more than one values for the specified name, the first value is returned.- Parameters:
name- the name of the header to searchdefaultValue- the default value- Returns:
- the first header value if the header is found and its value is a short.
defaultValueif there's no such header or its value is not a short.
-
getTimeMillis
public abstract java.lang.Long getTimeMillis(java.lang.CharSequence name)
Returns the date value of a header with the specified name. If there are more than one values for the specified name, the first value is returned.- Parameters:
name- the name of the header to search- Returns:
- the first header value if the header is found and its value is a date.
nullif there's no such header or its value is not a date.
-
getTimeMillis
public abstract long getTimeMillis(java.lang.CharSequence name, long defaultValue)Returns the date value of a header with the specified name. If there are more than one values for the specified name, the first value is returned.- Parameters:
name- the name of the header to searchdefaultValue- the default value- Returns:
- the first header value if the header is found and its value is a date.
defaultValueif there's no such header or its value is not a date.
-
getAll
public abstract java.util.List<java.lang.String> getAll(java.lang.String name)
- See Also:
getAll(CharSequence)
-
getAll
public java.util.List<java.lang.String> getAll(java.lang.CharSequence name)
Returns the values of headers with the specified name- Parameters:
name- The name of the headers to search- Returns:
- A
Listof header values which will be empty if no values are found - See Also:
getAllAsString(CharSequence)
-
entries
public abstract java.util.List<java.util.Map.Entry<java.lang.String,java.lang.String>> entries()
Returns a newListthat contains all headers in this object. Note that modifying the returnedListwill not affect the state of this object. If you intend to enumerate over the header entries only, useiterator()instead, which has much less overhead.- See Also:
iteratorCharSequence()
-
contains
public abstract boolean contains(java.lang.String name)
- See Also:
contains(CharSequence)
-
iterator
@Deprecated public abstract java.util.Iterator<java.util.Map.Entry<java.lang.String,java.lang.String>> iterator()
Deprecated.It is preferred to useiteratorCharSequence()unless you needString. IfStringis required then useiteratorAsString().- Specified by:
iteratorin interfacejava.lang.Iterable<java.util.Map.Entry<java.lang.String,java.lang.String>>
-
iteratorCharSequence
public abstract java.util.Iterator<java.util.Map.Entry<java.lang.CharSequence,java.lang.CharSequence>> iteratorCharSequence()
- Returns:
- Iterator over the name/value header pairs.
-
valueStringIterator
public java.util.Iterator<java.lang.String> valueStringIterator(java.lang.CharSequence name)
Equivalent togetAll(String)but it is possible that no intermediate list is generated.- Parameters:
name- the name of the header to retrieve- Returns:
- an
Iteratorof header values corresponding toname.
-
valueCharSequenceIterator
public java.util.Iterator<? extends java.lang.CharSequence> valueCharSequenceIterator(java.lang.CharSequence name)
Equivalent togetAll(String)but it is possible that no intermediate list is generated.- Parameters:
name- the name of the header to retrieve- Returns:
- an
Iteratorof header values corresponding toname.
-
contains
public boolean contains(java.lang.CharSequence name)
Checks to see if there is a header with the specified name- Parameters:
name- The name of the header to search for- Returns:
- True if at least one header is found
-
isEmpty
public abstract boolean isEmpty()
Checks if no header exists.
-
size
public abstract int size()
Returns the number of headers in this object.
-
names
public abstract java.util.Set<java.lang.String> names()
Returns a newSetthat contains the names of all headers in this object. Note that modifying the returnedSetwill not affect the state of this object. If you intend to enumerate over the header entries only, useiterator()instead, which has much less overhead.
-
add
public abstract HttpHeaders add(java.lang.String name, java.lang.Object value)
- See Also:
add(CharSequence, Object)
-
add
public HttpHeaders add(java.lang.CharSequence name, java.lang.Object value)
Adds a new header with the specified name and value. If the specified value is not aString, it is converted into aStringbyObject.toString(), except in the cases ofDateandCalendar, which are formatted to the date format defined in RFC2616.- Parameters:
name- The name of the header being addedvalue- The value of the header being added- Returns:
this
-
add
public abstract HttpHeaders add(java.lang.String name, java.lang.Iterable<?> values)
- See Also:
add(CharSequence, Iterable)
-
add
public HttpHeaders add(java.lang.CharSequence name, java.lang.Iterable<?> values)
Adds a new header with the specified name and values. This getMethod can be represented approximately as the following code:for (Object v: values) { if (v == null) { break; } headers.add(name, v); }- Parameters:
name- The name of the headers being setvalues- The values of the headers being set- Returns:
this
-
add
public HttpHeaders add(HttpHeaders headers)
Adds all header entries of the specifiedheaders.- Returns:
this
-
addInt
public abstract HttpHeaders addInt(java.lang.CharSequence name, int value)
Add thenametovalue.- Parameters:
name- The name to modifyvalue- The value- Returns:
this
-
addShort
public abstract HttpHeaders addShort(java.lang.CharSequence name, short value)
Add thenametovalue.- Parameters:
name- The name to modifyvalue- The value- Returns:
this
-
set
public abstract HttpHeaders set(java.lang.String name, java.lang.Object value)
- See Also:
set(CharSequence, Object)
-
set
public HttpHeaders set(java.lang.CharSequence name, java.lang.Object value)
Sets a header with the specified name and value. If there is an existing header with the same name, it is removed. If the specified value is not aString, it is converted into aStringbyObject.toString(), except forDateandCalendar, which are formatted to the date format defined in RFC2616.- Parameters:
name- The name of the header being setvalue- The value of the header being set- Returns:
this
-
set
public abstract HttpHeaders set(java.lang.String name, java.lang.Iterable<?> values)
- See Also:
set(CharSequence, Iterable)
-
set
public HttpHeaders set(java.lang.CharSequence name, java.lang.Iterable<?> values)
Sets a header with the specified name and values. If there is an existing header with the same name, it is removed. This getMethod can be represented approximately as the following code:headers.remove(name); for (Object v: values) { if (v == null) { break; } headers.add(name, v); }- Parameters:
name- The name of the headers being setvalues- The values of the headers being set- Returns:
this
-
set
public HttpHeaders set(HttpHeaders headers)
Cleans the current header entries and copies all header entries of the specifiedheaders.- Returns:
this
-
setAll
public HttpHeaders setAll(HttpHeaders headers)
Retains all current headers but callsset(String, Object)for each entry inheaders- Parameters:
headers- The headers used toset(String, Object)values in this instance- Returns:
this
-
setInt
public abstract HttpHeaders setInt(java.lang.CharSequence name, int value)
Set thenametovalue. This will remove all previous values associated withname.- Parameters:
name- The name to modifyvalue- The value- Returns:
this
-
setShort
public abstract HttpHeaders setShort(java.lang.CharSequence name, short value)
Set thenametovalue. This will remove all previous values associated withname.- Parameters:
name- The name to modifyvalue- The value- Returns:
this
-
remove
public abstract HttpHeaders remove(java.lang.String name)
- See Also:
remove(CharSequence)
-
remove
public HttpHeaders remove(java.lang.CharSequence name)
Removes the header with the specified name.- Parameters:
name- The name of the header to remove- Returns:
this
-
clear
public abstract HttpHeaders clear()
Removes all headers from thisHttpMessage.- Returns:
this
-
contains
public boolean contains(java.lang.String name, java.lang.String value, boolean ignoreCase)
-
containsValue
public boolean containsValue(java.lang.CharSequence name, java.lang.CharSequence value, boolean ignoreCase)Returnstrueif a header with thenameandvalueexists,falseotherwise. This also handles multiple values that are separated with a,.If
ignoreCaseistruethen a case insensitive compare is done on the value.- Parameters:
name- the name of the header to findvalue- the value of the header to findignoreCase-truethen a case insensitive compare is run to compare values. otherwise a case sensitive compare is run to compare values.
-
getAsString
public final java.lang.String getAsString(java.lang.CharSequence name)
Headers.get(Object)and convert the result to aString.- Parameters:
name- the name of the header to retrieve- Returns:
- the first header value if the header is found.
nullif there's no such header.
-
getAllAsString
public final java.util.List<java.lang.String> getAllAsString(java.lang.CharSequence name)
- Parameters:
name- the name of the header to retrieve- Returns:
- a
Listof header values or an emptyListif no values are found.
-
iteratorAsString
public final java.util.Iterator<java.util.Map.Entry<java.lang.String,java.lang.String>> iteratorAsString()
Iteratorthat converts eachMap.Entry's key and value to aString.
-
contains
public boolean contains(java.lang.CharSequence name, java.lang.CharSequence value, boolean ignoreCase)Returnstrueif a header with thenameandvalueexists,falseotherwise.If
ignoreCaseistruethen a case insensitive compare is done on the value.- Parameters:
name- the name of the header to findvalue- the value of the header to findignoreCase-truethen a case insensitive compare is run to compare values. otherwise a case sensitive compare is run to compare values.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
copy
public HttpHeaders copy()
Returns a deep copy of the passed inHttpHeaders.
-
-