Package io.netty.handler.codec.http
Class HttpHeaders
java.lang.Object
io.netty.handler.codec.http.HttpHeaders
- Direct Known Subclasses:
DefaultHttpHeaders
,EmptyHttpHeaders
,ReadOnlyHttpHeaders
Provides the constants for the standard HTTP header names and values and
commonly used utility methods that accesses an
HttpMessage
.
Concrete instances of this class are most easily obtained from its default factory:
DefaultHttpHeadersFactory.headersFactory()
.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final class
Deprecated.static final class
Deprecated.UseHttpHeaderValues
instead. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionadd
(HttpHeaders headers) Adds all header entries of the specifiedheaders
.add
(CharSequence name, Iterable<?> values) Adds a new header with the specified name and values.add
(CharSequence name, Object value) Adds a new header with the specified name and value.abstract HttpHeaders
abstract HttpHeaders
static void
addDateHeader
(HttpMessage message, CharSequence name, Date value) Deprecated.Useadd(CharSequence, Object)
instead.static void
addDateHeader
(HttpMessage message, String name, Date value) Deprecated.Useadd(CharSequence, Object)
instead.static void
addHeader
(HttpMessage message, CharSequence name, Object value) Deprecated.Useadd(CharSequence, Object)
instead.static void
addHeader
(HttpMessage message, String name, Object value) Deprecated.Useadd(CharSequence, Object)
instead.abstract HttpHeaders
addInt
(CharSequence name, int value) Add thename
tovalue
.static void
addIntHeader
(HttpMessage message, CharSequence name, int value) Deprecated.UseaddInt(CharSequence, int)
instead.static void
addIntHeader
(HttpMessage message, String name, int value) Deprecated.Useadd(CharSequence, Iterable)
instead.abstract HttpHeaders
addShort
(CharSequence name, short value) Add thename
tovalue
.abstract HttpHeaders
clear()
Removes all headers from thisHttpMessage
.static void
clearHeaders
(HttpMessage message) Deprecated.Useclear()
instead.boolean
contains
(CharSequence name) Checks to see if there is a header with the specified nameboolean
contains
(CharSequence name, CharSequence value, boolean ignoreCase) Returnstrue
if a header with thename
andvalue
exists,false
otherwise.abstract boolean
boolean
private static boolean
containsCommaSeparatedTrimmed
(CharSequence rawNext, CharSequence expected, boolean ignoreCase) boolean
containsValue
(CharSequence name, CharSequence value, boolean ignoreCase) Returnstrue
if a header with thename
andvalue
exists,false
otherwise.copy()
Returns a deep copy of the passed inHttpHeaders
.static void
encodeAscii
(CharSequence seq, ByteBuf buf) Deprecated.entries()
Returns a newList
that contains all headers in this object.static boolean
equalsIgnoreCase
(CharSequence name1, CharSequence name2) Deprecated.get
(CharSequence name) Returns the value of a header with the specified name.get
(CharSequence name, String defaultValue) Returns the value of a header with the specified name.abstract String
getAll
(CharSequence name) Returns the values of headers with the specified namegetAllAsString
(CharSequence name) final String
getAsString
(CharSequence name) Headers.get(Object)
and convert the result to aString
.static long
getContentLength
(HttpMessage message) Deprecated.UseHttpUtil.getContentLength(HttpMessage)
instead.static long
getContentLength
(HttpMessage message, long defaultValue) Deprecated.UseHttpUtil.getContentLength(HttpMessage, long)
instead.static Date
getDate
(HttpMessage message) Deprecated.UsegetTimeMillis(CharSequence)
instead.static Date
getDate
(HttpMessage message, Date defaultValue) Deprecated.UsegetTimeMillis(CharSequence, long)
instead.static Date
getDateHeader
(HttpMessage message, CharSequence name) Deprecated.UsegetTimeMillis(CharSequence)
instead.static Date
getDateHeader
(HttpMessage message, CharSequence name, Date defaultValue) Deprecated.UsegetTimeMillis(CharSequence, long)
instead.static Date
getDateHeader
(HttpMessage message, String name) Deprecated.UsegetTimeMillis(CharSequence)
instead.static Date
getDateHeader
(HttpMessage message, String name, Date defaultValue) Deprecated.UsegetTimeMillis(CharSequence, long)
instead.static String
getHeader
(HttpMessage message, CharSequence name) Deprecated.Useget(CharSequence)
instead.static String
getHeader
(HttpMessage message, CharSequence name, String defaultValue) Deprecated.Useget(CharSequence, String)
instead.static String
getHeader
(HttpMessage message, String name) Deprecated.Useget(CharSequence)
instead.static String
getHeader
(HttpMessage message, String name, String defaultValue) Deprecated.Useget(CharSequence, String)
instead.static String
getHost
(HttpMessage message) Deprecated.Useget(CharSequence)
instead.static String
getHost
(HttpMessage message, String defaultValue) Deprecated.Useget(CharSequence, String)
instead.abstract Integer
getInt
(CharSequence name) Returns the integer value of a header with the specified name.abstract int
getInt
(CharSequence name, int defaultValue) Returns the integer value of a header with the specified name.static int
getIntHeader
(HttpMessage message, CharSequence name) Deprecated.UsegetInt(CharSequence)
instead.static int
getIntHeader
(HttpMessage message, CharSequence name, int defaultValue) Deprecated.UsegetInt(CharSequence, int)
instead.static int
getIntHeader
(HttpMessage message, String name) Deprecated.UsegetInt(CharSequence)
instead.static int
getIntHeader
(HttpMessage message, String name, int defaultValue) Deprecated.UsegetInt(CharSequence, int)
instead.abstract Short
getShort
(CharSequence name) Returns the short value of a header with the specified name.abstract short
getShort
(CharSequence name, short defaultValue) Returns the short value of a header with the specified name.abstract Long
getTimeMillis
(CharSequence name) Returns the date value of a header with the specified name.abstract long
getTimeMillis
(CharSequence name, long defaultValue) Returns the date value of a header with the specified name.static boolean
is100ContinueExpected
(HttpMessage message) Deprecated.UseHttpUtil.is100ContinueExpected(HttpMessage)
instead.static boolean
Deprecated.UseHttpUtil.isContentLengthSet(HttpMessage)
instead.abstract boolean
isEmpty()
Checks if no header exists.static boolean
isKeepAlive
(HttpMessage message) Deprecated.UseHttpUtil.isKeepAlive(HttpMessage)
instead.static boolean
isTransferEncodingChunked
(HttpMessage message) Deprecated.UseHttpUtil.isTransferEncodingChunked(HttpMessage)
instead.iterator()
Deprecated.It is preferred to useiteratorCharSequence()
unless you needString
.abstract Iterator
<Map.Entry<CharSequence, CharSequence>> names()
Returns a newSet
that contains the names of all headers in this object.static CharSequence
Deprecated.UseAsciiString
instead.remove
(CharSequence name) Removes the header with the specified name.abstract HttpHeaders
static void
removeHeader
(HttpMessage message, CharSequence name) Deprecated.Useremove(CharSequence)
instead.static void
removeHeader
(HttpMessage message, String name) Deprecated.Useremove(CharSequence)
instead.static void
Deprecated.set
(HttpHeaders headers) Cleans the current header entries and copies all header entries of the specifiedheaders
.set
(CharSequence name, Iterable<?> values) Sets a header with the specified name and values.set
(CharSequence name, Object value) Sets a header with the specified name and value.abstract HttpHeaders
abstract HttpHeaders
static void
set100ContinueExpected
(HttpMessage message) Deprecated.static void
set100ContinueExpected
(HttpMessage message, boolean set) Deprecated.setAll
(HttpHeaders headers) Retains all current headers but callsset(String, Object)
for each entry inheaders
static void
setContentLength
(HttpMessage message, long length) Deprecated.UseHttpUtil.setContentLength(HttpMessage, long)
instead.static void
setDate
(HttpMessage message, Date value) Deprecated.Useset(CharSequence, Object)
instead.static void
setDateHeader
(HttpMessage message, CharSequence name, Iterable<Date> values) Deprecated.Useset(CharSequence, Iterable)
instead.static void
setDateHeader
(HttpMessage message, CharSequence name, Date value) Deprecated.Useset(CharSequence, Object)
instead.static void
setDateHeader
(HttpMessage message, String name, Iterable<Date> values) Deprecated.Useset(CharSequence, Iterable)
instead.static void
setDateHeader
(HttpMessage message, String name, Date value) Deprecated.Useset(CharSequence, Object)
instead.static void
setHeader
(HttpMessage message, CharSequence name, Iterable<?> values) Deprecated.Useset(CharSequence, Iterable)
instead.static void
setHeader
(HttpMessage message, CharSequence name, Object value) Deprecated.Useset(CharSequence, Object)
instead.static void
setHeader
(HttpMessage message, String name, Iterable<?> values) Deprecated.Useset(CharSequence, Iterable)
instead.static void
setHeader
(HttpMessage message, String name, Object value) Deprecated.Useset(CharSequence, Object)
instead.static void
setHost
(HttpMessage message, CharSequence value) Deprecated.Useset(CharSequence, Object)
instead.static void
setHost
(HttpMessage message, String value) Deprecated.Useset(CharSequence, Object)
instead.abstract HttpHeaders
setInt
(CharSequence name, int value) Set thename
tovalue
.static void
setIntHeader
(HttpMessage message, CharSequence name, int value) Deprecated.UsesetInt(CharSequence, int)
instead.static void
setIntHeader
(HttpMessage message, CharSequence name, Iterable<Integer> values) Deprecated.Useset(CharSequence, Iterable)
instead.static void
setIntHeader
(HttpMessage message, String name, int value) Deprecated.UsesetInt(CharSequence, int)
instead.static void
setIntHeader
(HttpMessage message, String name, Iterable<Integer> values) Deprecated.Useset(CharSequence, Iterable)
instead.static void
setKeepAlive
(HttpMessage message, boolean keepAlive) Deprecated.UseHttpUtil.setKeepAlive(HttpMessage, boolean)
instead.abstract HttpHeaders
setShort
(CharSequence name, short value) Set thename
tovalue
.static void
Deprecated.abstract int
size()
Returns the number of headers in this object.toString()
Iterator
<? extends CharSequence> Equivalent togetAll(String)
but it is possible that no intermediate list is generated.Equivalent togetAll(String)
but it is possible that no intermediate list is generated.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
EMPTY_HEADERS
Deprecated.UseEmptyHttpHeaders.INSTANCE
.The instance is instantiated here to break the cyclic static initialization between
EmptyHttpHeaders
andHttpHeaders
. The issue is that if someone accessesEmptyHttpHeaders.INSTANCE
beforeEMPTY_HEADERS
thenEMPTY_HEADERS
will benull
.
-
-
Constructor Details
-
HttpHeaders
protected HttpHeaders()
-
-
Method Details
-
isKeepAlive
Deprecated.UseHttpUtil.isKeepAlive(HttpMessage)
instead. Returnstrue
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 ofHttpVersion.isKeepAliveDefault()
. -
setKeepAlive
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"
ifkeepAlive
isfalse
. - remove otherwise.
- set to
- If the connection is closed by default:
- set to
"keep-alive"
ifkeepAlive
istrue
. - remove otherwise.
- set to
- If the connection is kept alive by default:
-
getHeader
Deprecated.Useget(CharSequence)
instead. -
getHeader
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
null
if there is no such header
-
getHeader
Deprecated.Useget(CharSequence, String)
instead.- See Also:
-
getHeader
@Deprecated public static String getHeader(HttpMessage message, CharSequence name, 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
defaultValue
if there is no such header
-
setHeader
Deprecated.Useset(CharSequence, Object)
instead.- See Also:
-
setHeader
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 aString
byObject.toString()
, except forDate
andCalendar
which are formatted to the date format defined in RFC2616. -
setHeader
Deprecated.Useset(CharSequence, Iterable)
instead.- See Also:
-
setHeader
@Deprecated public static void setHeader(HttpMessage message, CharSequence name, 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.Useadd(CharSequence, Object)
instead.- See Also:
-
addHeader
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 aString
byObject.toString()
, except forDate
andCalendar
which are formatted to the date format defined in RFC2616. -
removeHeader
Deprecated.Useremove(CharSequence)
instead.- See Also:
-
removeHeader
Deprecated.Useremove(CharSequence)
instead. Removes the header with the specified name. -
clearHeaders
Deprecated.Useclear()
instead. Removes all headers from the specified message. -
getIntHeader
Deprecated.UsegetInt(CharSequence)
instead.- See Also:
-
getIntHeader
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:
NumberFormatException
- if there is no such header or the header value is not a number
-
getIntHeader
Deprecated.UsegetInt(CharSequence, int)
instead.- See Also:
-
getIntHeader
@Deprecated public static int getIntHeader(HttpMessage message, 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
defaultValue
if there is no such header or the header value is not a number
-
setIntHeader
Deprecated.UsesetInt(CharSequence, int)
instead.- See Also:
-
setIntHeader
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, String name, Iterable<Integer> values) Deprecated.Useset(CharSequence, Iterable)
instead.- See Also:
-
setIntHeader
@Deprecated public static void setIntHeader(HttpMessage message, CharSequence name, Iterable<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.Useadd(CharSequence, Iterable)
instead.- See Also:
-
addIntHeader
Deprecated.UseaddInt(CharSequence, int)
instead. Adds a new integer header with the specified name and value. -
getDateHeader
@Deprecated public static Date getDateHeader(HttpMessage message, String name) throws ParseException Deprecated.UsegetTimeMillis(CharSequence)
instead.- Throws:
ParseException
- See Also:
-
getDateHeader
@Deprecated public static Date getDateHeader(HttpMessage message, CharSequence name) throws 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:
ParseException
- if there is no such header or the header value is not a formatted date
-
getDateHeader
Deprecated.UsegetTimeMillis(CharSequence, long)
instead.- See Also:
-
getDateHeader
@Deprecated public static Date getDateHeader(HttpMessage message, CharSequence name, 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
defaultValue
if there is no such header or the header value is not a formatted date
-
setDateHeader
Deprecated.Useset(CharSequence, Object)
instead.- See Also:
-
setDateHeader
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, String name, Iterable<Date> values) Deprecated.Useset(CharSequence, Iterable)
instead.- See Also:
-
setDateHeader
@Deprecated public static void setDateHeader(HttpMessage message, CharSequence name, Iterable<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.Useadd(CharSequence, Object)
instead.- See Also:
-
addDateHeader
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.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:
NumberFormatException
- if the message does not have the"Content-Length"
header or its value is not a number
-
getContentLength
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
defaultValue
if this message does not have the"Content-Length"
header or its value is not a number
-
setContentLength
Deprecated.UseHttpUtil.setContentLength(HttpMessage, long)
instead. -
getHost
Deprecated.Useget(CharSequence)
instead. Returns the value of the"Host"
header. -
getHost
Deprecated.Useget(CharSequence, String)
instead. Returns the value of the"Host"
header. If there is no such header, thedefaultValue
is returned. -
setHost
Deprecated.Useset(CharSequence, Object)
instead.- See Also:
-
setHost
Deprecated.Useset(CharSequence, Object)
instead. Sets the"Host"
header. -
getDate
Deprecated.UsegetTimeMillis(CharSequence)
instead. Returns the value of the"Date"
header.- Throws:
ParseException
- if there is no such header or the header value is not a formatted date
-
getDate
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, thedefaultValue
is returned. -
setDate
Deprecated.Useset(CharSequence, Object)
instead. Sets the"Date"
header. -
is100ContinueExpected
Deprecated.UseHttpUtil.is100ContinueExpected(HttpMessage)
instead. Returnstrue
if and only if the specified message contains the"Expect: 100-continue"
header. -
set100ContinueExpected
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.UseHttpUtil.set100ContinueExpected(HttpMessage, boolean)
instead. Sets or removes the"Expect: 100-continue"
header to / from the specified message. Ifset
istrue
, the"Expect: 100-continue"
header is set and all other previous"Expect"
headers are removed. Otherwise, all"Expect"
headers are removed completely. -
isTransferEncodingChunked
Deprecated.UseHttpUtil.isTransferEncodingChunked(HttpMessage)
instead. Checks to see if the transfer encoding in a specifiedHttpMessage
is chunked- Parameters:
message
- The message to check- Returns:
- True if transfer encoding is chunked, otherwise false
-
removeTransferEncodingChunked
Deprecated. -
setTransferEncodingChunked
Deprecated. -
isContentLengthSet
Deprecated.UseHttpUtil.isContentLengthSet(HttpMessage)
instead. -
equalsIgnoreCase
Deprecated. -
encodeAscii
Deprecated. -
newEntity
Deprecated.UseAsciiString
instead.Create a new
CharSequence
which is optimized for reuse asHttpHeaders
name or value. So if you have a Header name or value that you want to reuse you should make use of this. -
get
- See Also:
-
get
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
null
if there is no such header - See Also:
-
get
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
defaultValue
if there is no such header
-
getInt
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.
null
if there's no such header or its value is not an integer.
-
getInt
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.
defaultValue
if there's no such header or its value is not an integer.
-
getShort
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.
null
if there's no such header or its value is not a short.
-
getShort
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.
defaultValue
if there's no such header or its value is not a short.
-
getTimeMillis
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.
null
if there's no such header or its value is not a date.
-
getTimeMillis
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.
defaultValue
if there's no such header or its value is not a date.
-
getAll
- See Also:
-
getAll
Returns the values of headers with the specified name- Parameters:
name
- The name of the headers to search- Returns:
- A
List
of header values which will be empty if no values are found - See Also:
-
entries
Returns a newList
that contains all headers in this object. Note that modifying the returnedList
will 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:
-
contains
- See Also:
-
iterator
Deprecated.It is preferred to useiteratorCharSequence()
unless you needString
. IfString
is required then useiteratorAsString()
. -
iteratorCharSequence
- Returns:
- Iterator over the name/value header pairs.
-
valueStringIterator
Equivalent togetAll(String)
but it is possible that no intermediate list is generated.- Parameters:
name
- the name of the header to retrieve- Returns:
- an
Iterator
of header values corresponding toname
.
-
valueCharSequenceIterator
Equivalent togetAll(String)
but it is possible that no intermediate list is generated.- Parameters:
name
- the name of the header to retrieve- Returns:
- an
Iterator
of header values corresponding toname
.
-
contains
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
Returns a newSet
that contains the names of all headers in this object. Note that modifying the returnedSet
will 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
- See Also:
-
add
Adds a new header with the specified name and value. If the specified value is not aString
, it is converted into aString
byObject.toString()
, except in the cases ofDate
andCalendar
, 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
- See Also:
-
add
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
Adds all header entries of the specifiedheaders
.- Returns:
this
-
addInt
Add thename
tovalue
.- Parameters:
name
- The name to modifyvalue
- The value- Returns:
this
-
addShort
Add thename
tovalue
.- Parameters:
name
- The name to modifyvalue
- The value- Returns:
this
-
set
- See Also:
-
set
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 aString
byObject.toString()
, except forDate
andCalendar
, 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
- See Also:
-
set
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
Cleans the current header entries and copies all header entries of the specifiedheaders
.- Returns:
this
-
setAll
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
Set thename
tovalue
. This will remove all previous values associated withname
.- Parameters:
name
- The name to modifyvalue
- The value- Returns:
this
-
setShort
Set thename
tovalue
. This will remove all previous values associated withname
.- Parameters:
name
- The name to modifyvalue
- The value- Returns:
this
-
remove
- See Also:
-
remove
Removes the header with the specified name.- Parameters:
name
- The name of the header to remove- Returns:
this
-
clear
Removes all headers from thisHttpMessage
.- Returns:
this
-
contains
- See Also:
-
containsValue
Returnstrue
if a header with thename
andvalue
exists,false
otherwise. This also handles multiple values that are separated with a,
.If
ignoreCase
istrue
then 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
-true
then a case insensitive compare is run to compare values. otherwise a case sensitive compare is run to compare values.
-
containsCommaSeparatedTrimmed
private static boolean containsCommaSeparatedTrimmed(CharSequence rawNext, CharSequence expected, boolean ignoreCase) -
getAsString
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.
null
if there's no such header.
-
getAllAsString
-
iteratorAsString
-
contains
Returnstrue
if a header with thename
andvalue
exists,false
otherwise.If
ignoreCase
istrue
then 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
-true
then a case insensitive compare is run to compare values. otherwise a case sensitive compare is run to compare values.
-
toString
-
copy
Returns a deep copy of the passed inHttpHeaders
.
-
HttpHeaderNames
instead.