Top Description Inners Fields Constructors Methods
io.netty.handler.codec.http

public abstract Class HttpHeaders

extends Object
implements Iterable<Map.Entry<String, String>>
Class Inheritance
All Implemented Interfaces
java.lang.Iterable
Known Direct Subclasses
io.netty.handler.codec.http.ReadOnlyHttpHeaders, io.netty.handler.codec.http.EmptyHttpHeaders, io.netty.handler.codec.http.DefaultHttpHeaders
Imports
io.netty.buffer.ByteBuf, .ByteBufUtil, io.netty.handler.codec.DateFormatter, .Headers, .HeadersUtils, io.netty.util.AsciiString, .CharsetUtil, io.netty.util.internal.ObjectUtil, java.text.ParseException, java.util.Calendar, .Date, .Iterator, .List, .Map, .Map.Entry, .Set

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 and Inner Type Summary

Modifier and TypeClass and Description
public static class
HttpHeaders.Names

Deprecated Use HttpHeaderNames instead. Standard HTTP header names.
public static class
HttpHeaders.Values

Deprecated Use HttpHeaderValues instead. Standard HTTP header values.

Field Summary

Modifier and TypeField and Description
public static final HttpHeaders

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Modifier and TypeMethod and Description
public abstract HttpHeaders
add(String name, Object value)

public HttpHeaders

Returns:

this
add
(CharSequence
The name of the header being added
name
,
Object
The value of the header being added
value
)

Adds a new header with the specified name and value.

public abstract HttpHeaders
add(String name, Iterable<?> values)

public HttpHeaders

Returns:

this
add
(CharSequence
The name of the headers being set
name
,
Iterable<?>
The values of the headers being set
values
)

Adds a new header with the specified name and values.

public HttpHeaders

Returns:

this
add
(HttpHeaders headers)

Adds all header entries of the specified headers.

public static void
addDateHeader(HttpMessage message, String name, Date value)

Deprecated Use add(CharSequence, Object) instead.
public static void
addDateHeader(HttpMessage message, CharSequence name, Date value)

Deprecated Use add(CharSequence, Object) instead.
public static void
addHeader(HttpMessage message, String name, Object value)

Deprecated Use add(CharSequence, Object) instead.
public static void
addHeader(HttpMessage message, CharSequence name, Object value)

Deprecated Use add(CharSequence, Object) instead.
public abstract HttpHeaders

Returns:

this
addInt
(CharSequence
The name to modify
name
,
int
The value
value
)

Add the name to value.

public static void
addIntHeader(HttpMessage message, String name, int value)

Deprecated Use add(CharSequence, Iterable) instead.
public static void
addIntHeader(HttpMessage message, CharSequence name, int value)

Deprecated Use addInt(CharSequence, int) instead. Adds a new integer header with the specified name and value.
public abstract HttpHeaders

Returns:

this
addShort
(CharSequence
The name to modify
name
,
short
The value
value
)

Add the name to value.

public abstract HttpHeaders

Returns:

this
clear
()

Removes all headers from this HttpMessage.

public static void
clearHeaders(HttpMessage message)

Deprecated Use clear() instead. Removes all headers from the specified message.
public abstract boolean
public boolean

Returns:

True if at least one header is found
contains
(CharSequence
The name of the header to search for
name
)

Checks to see if there is a header with the specified name

public boolean
contains(String name, String value, boolean ignoreCase)

public boolean
contains(CharSequence
the name of the header to find
name
,
CharSequence
the value of the header to find
value
,
boolean
true then a case insensitive compare is run to compare values. otherwise a case sensitive compare is run to compare values.
ignoreCase
)

Returns true if a header with the name and value exists, false otherwise.

private static boolean
containsCommaSeparatedTrimmed(CharSequence rawNext, CharSequence expected, boolean ignoreCase)

public boolean
containsValue(CharSequence
the name of the header to find
name
,
CharSequence
the value of the header to find
value
,
boolean
true then a case insensitive compare is run to compare values. otherwise a case sensitive compare is run to compare values.
ignoreCase
)

Returns true if a header with the name and value exists, false otherwise.

public HttpHeaders
copy()

Returns a deep copy of the passed in HttpHeaders.

public static void
encodeAscii(CharSequence seq, ByteBuf buf)

Deprecated
public abstract List<Map.Entry<String, String>>
entries()

Returns a new List that contains all headers in this object.

public static boolean
public abstract String
get(String name)

public String

Returns:

The first header value or null if there is no such header
get
(CharSequence
The name of the header to search
name
)

Returns the value of a header with the specified name.

public String

Returns:

The first header value or defaultValue if there is no such header
get
(CharSequence
The name of the header to search
name
,
String defaultValue)

Returns the value of a header with the specified name.

public abstract List<String>
getAll(String name)

public List<String>

Returns:

A List of header values which will be empty if no values are found
getAll
(CharSequence
The name of the headers to search
name
)

Returns the values of headers with the specified name

public final List<String>

Returns:

a List of header values or an empty List if no values are found.
getAllAsString
(CharSequence
the name of the header to retrieve
name
)

Headers#getAll(Object) and convert each element of List to a String.

public final String

Returns:

the first header value if the header is found. null if there's no such header.
getAsString
(CharSequence
the name of the header to retrieve
name
)

Headers#get(Object) and convert the result to a String.

public static long

Returns:

the content length
getContentLength
(HttpMessage message)

Deprecated Use HttpUtil#getContentLength(HttpMessage) instead.
public static long

Returns:

the content length or defaultValue if this message does not have the "Content-Length" header or its value is not a number
getContentLength
(HttpMessage message, long defaultValue)

public static Date
getDate(HttpMessage message)

Deprecated Use getTimeMillis(CharSequence) instead. Returns the value of the "Date" header.
public static Date
getDate(HttpMessage message, Date defaultValue)

Deprecated Use getTimeMillis(CharSequence, long) instead.
public static Date
getDateHeader(HttpMessage message, String name)

Deprecated Use getTimeMillis(CharSequence) instead.
public static Date

Returns:

the header value
getDateHeader
(HttpMessage message, CharSequence name)

Deprecated Use getTimeMillis(CharSequence) instead.
public static Date
getDateHeader(HttpMessage message, String name, Date defaultValue)

Deprecated Use getTimeMillis(CharSequence, long) instead.
public static Date

Returns:

the header value or the defaultValue if there is no such header or the header value is not a formatted date
getDateHeader
(HttpMessage message, CharSequence name, Date defaultValue)

Deprecated Use getTimeMillis(CharSequence, long) instead.
public static String
getHeader(HttpMessage message, String name)

Deprecated Use get(CharSequence) instead.
public static String

Returns:

the header value or null if there is no such header
getHeader
(HttpMessage message, CharSequence name)

Deprecated Use get(CharSequence) instead.
public static String
getHeader(HttpMessage message, String name, String defaultValue)

Deprecated Use get(CharSequence, String) instead.
public static String

Returns:

the header value or the defaultValue if there is no such header
getHeader
(HttpMessage message, CharSequence name, String defaultValue)

Deprecated Use get(CharSequence, String) instead.
public static String
getHost(HttpMessage message)

Deprecated Use get(CharSequence) instead. Returns the value of the "Host" header.
public static String
getHost(HttpMessage message, String defaultValue)

Deprecated Use get(CharSequence, String) instead.
public abstract Integer

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
(CharSequence
the name of the header to search
name
)

Returns the integer value of a header with the specified name.

public abstract int

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.
getInt
(CharSequence
the name of the header to search
name
,
int
the default value
defaultValue
)

Returns the integer value of a header with the specified name.

public static int
getIntHeader(HttpMessage message, String name)

Deprecated Use getInt(CharSequence) instead.
public static int

Returns:

the header value
getIntHeader
(HttpMessage message, CharSequence name)

Deprecated Use getInt(CharSequence) instead.
public static int
getIntHeader(HttpMessage message, String name, int defaultValue)

Deprecated Use getInt(CharSequence, int) instead.
public static int

Returns:

the header value or the defaultValue if there is no such header or the header value is not a number
getIntHeader
(HttpMessage message, CharSequence name, int defaultValue)

Deprecated Use getInt(CharSequence, int) instead.
public abstract Short

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
(CharSequence
the name of the header to search
name
)

Returns the short value of a header with the specified name.

public abstract short

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.
getShort
(CharSequence
the name of the header to search
name
,
short
the default value
defaultValue
)

Returns the short value of a header with the specified name.

public abstract Long

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
(CharSequence
the name of the header to search
name
)

Returns the date value of a header with the specified name.

public abstract long

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.
getTimeMillis
(CharSequence
the name of the header to search
name
,
long
the default value
defaultValue
)

Returns the date value of a header with the specified name.

public static boolean
public static boolean
public abstract boolean
isEmpty()

Checks if no header exists.

public static boolean
public static boolean

Returns:

True if transfer encoding is chunked, otherwise false
isTransferEncodingChunked
(HttpMessage
The message to check
message
)

public abstract Iterator<Map.Entry<String, String>>
iterator()

Redeclares java.lang.Iterable.iterator.

Deprecated It is preferred to use iteratorCharSequence() unless you need String.
Returns an iterator over elements of type T.
public final Iterator<Map.Entry<String, String>>
iteratorAsString()

Iterator that converts each Entry's key and value to a String.

public abstract Iterator<Map.Entry<CharSequence, CharSequence>>

Returns:

Iterator over the name/value header pairs.
iteratorCharSequence
()

public abstract Set<String>
names()

Returns a new Set that contains the names of all headers in this object.

public static CharSequence
newEntity(String name)

Deprecated Use AsciiString instead.
public abstract HttpHeaders
remove(String name)

public HttpHeaders

Returns:

this
remove
(CharSequence
The name of the header to remove
name
)

Removes the header with the specified name.

public static void
removeHeader(HttpMessage message, String name)

Deprecated Use remove(CharSequence) instead.
public static void
removeHeader(HttpMessage message, CharSequence name)

Deprecated Use remove(CharSequence) instead. Removes the header with the specified name.
public static void
public abstract HttpHeaders
set(String name, Object value)

public HttpHeaders

Returns:

this
set
(CharSequence
The name of the header being set
name
,
Object
The value of the header being set
value
)

Sets a header with the specified name and value.

public abstract HttpHeaders
set(String name, Iterable<?> values)

public HttpHeaders

Returns:

this
set
(CharSequence
The name of the headers being set
name
,
Iterable<?>
The values of the headers being set
values
)

Sets a header with the specified name and values.

public HttpHeaders

Returns:

this
set
(HttpHeaders headers)

Cleans the current header entries and copies all header entries of the specified headers.

public static void
public static void
public HttpHeaders

Returns:

this
setAll
(HttpHeaders
The headers used to set(String, Object) values in this instance
headers
)

Retains all current headers but calls set(String, Object) for each entry in headers

public static void
setContentLength(HttpMessage message, long length)

public static void
setDate(HttpMessage message, Date value)

Deprecated Use set(CharSequence, Object) instead. Sets the "Date" header.
public static void
setDateHeader(HttpMessage message, String name, Date value)

Deprecated Use set(CharSequence, Object) instead.
public static void
setDateHeader(HttpMessage message, CharSequence name, Date value)

Deprecated Use set(CharSequence, Object) instead.
public static void
setDateHeader(HttpMessage message, String name, Iterable<Date> values)

Deprecated Use set(CharSequence, Iterable) instead.
public static void
setDateHeader(HttpMessage message, CharSequence name, Iterable<Date> values)

Deprecated Use set(CharSequence, Iterable) instead.
public static void
setHeader(HttpMessage message, String name, Object value)

Deprecated Use set(CharSequence, Object) instead.
public static void
setHeader(HttpMessage message, CharSequence name, Object value)

Deprecated Use set(CharSequence, Object) instead.
public static void
setHeader(HttpMessage message, String name, Iterable<?> values)

Deprecated Use set(CharSequence, Iterable) instead.
public static void
setHeader(HttpMessage message, CharSequence name, Iterable<?> values)

Deprecated Use set(CharSequence, Iterable) instead.
public static void
setHost(HttpMessage message, String value)

Deprecated Use set(CharSequence, Object) instead.
public static void
setHost(HttpMessage message, CharSequence value)

Deprecated Use set(CharSequence, Object) instead. Sets the "Host" header.
public abstract HttpHeaders

Returns:

this
setInt
(CharSequence
The name to modify
name
,
int
The value
value
)

Set the name to value.

public static void
setIntHeader(HttpMessage message, String name, int value)

Deprecated Use setInt(CharSequence, int) instead.
public static void
setIntHeader(HttpMessage message, CharSequence name, int value)

Deprecated Use setInt(CharSequence, int) instead.
public static void
setIntHeader(HttpMessage message, String name, Iterable<Integer> values)

Deprecated Use set(CharSequence, Iterable) instead.
public static void
setIntHeader(HttpMessage message, CharSequence name, Iterable<Integer> values)

Deprecated Use set(CharSequence, Iterable) instead.
public static void
setKeepAlive(HttpMessage message, boolean keepAlive)

public abstract HttpHeaders

Returns:

this
setShort
(CharSequence
The name to modify
name
,
short
The value
value
)

Set the name to value.

public static void
public abstract int
size()

Returns the number of headers in this object.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
public Iterator<? extends CharSequence>

Returns:

an Iterator of header values corresponding to name.
valueCharSequenceIterator
(CharSequence
the name of the header to retrieve
name
)

Equivalent to getAll(String) but it is possible that no intermediate list is generated.

public Iterator<String>

Returns:

an Iterator of header values corresponding to name.
valueStringIterator
(CharSequence
the name of the header to retrieve
name
)

Equivalent to getAll(String) but it is possible that no intermediate list is generated.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait