GeezerVison is showing netty.io — HttpHeaders (Netty API Reference (4.1.141.Final))
Class HttpHeaders
-
Nested Class Summary
Nested Classes
Modifier and Type
Class
Description
static final class
static final class
-
Field Summary
Fields
Modifier and Type
Field
Description
-
Constructor Summary
Constructors
Modifier
Constructor
Description
protected
-
Method Summary
Modifier and Type
Method
Description
Adds all header entries of the specified headers.
Adds a new header with the specified name and values.
Adds a new header with the specified name and value.
static void
static void
static void
static void
static void
static void
static void
boolean
Checks to see if there is a header with the specified name
boolean
Returns true if a header with the name and value exists, false otherwise.
abstract boolean
boolean
boolean
Returns true if a header with the name and value exists, false otherwise.
static void
Returns a new List that contains all headers in this object.
static boolean
Returns the value of a header with the specified name.
Returns the value of a header with the specified name.
Returns the values of headers with the specified name
static long
static long
Returns the integer value of a header with the specified name.
abstract int
Returns the integer value of a header with the specified name.
static int
static int
static int
static int
Returns the short value of a header with the specified name.
abstract short
Returns the short value of a header with the specified name.
Returns the date value of a header with the specified name.
abstract long
Returns the date value of a header with the specified name.
static boolean
static boolean
abstract boolean
Checks if no header exists.
static boolean
static boolean
Returns a new Set that contains the names of all headers in this object.
Removes the header with the specified name.
static void
static void
static void
Cleans the current header entries and copies all header entries of the specified headers.
Sets a header with the specified name and values.
Sets a header with the specified name and value.
static void
static void
static void
static void
static void
static void
static void
static void
static void
static void
static void
static void
static void
static void
static void
static void
static void
static void
static void
static void
abstract int
Returns the number of headers in this object.
Equivalent to getAll(String) but it is possible that no intermediate list is generated.
Equivalent to getAll(String) but it is possible that no intermediate list is generated.
-
-
-
Method Details
-
-
setKeepAlive
Deprecated.
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().
- If the connection is kept alive by default:
- set to
"close" if keepAlive is false.
- remove otherwise.
- If the connection is closed by default:
- set to
"keep-alive" if keepAlive is true.
- remove otherwise.
-
-
getHeader
Deprecated.
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.
- Returns:
- the header value or
null if there is no such header
-
-
getHeader
Deprecated.
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.
- Returns:
- the header value or the
defaultValue if there is no such
header
-
-
-
-
setHeader
Deprecated.
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);
}
-
-
-
-
-
clearHeaders
Deprecated.
Use clear() instead.
Removes all headers from the specified message.
-
-
getIntHeader
Deprecated.
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.
- Returns:
- the header value
- Throws:
NumberFormatException - if there is no such header or the header value is not a number
-
-
getIntHeader
Deprecated.
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.
- Returns:
- the header value or the
defaultValue if there is no such
header or the header value is not a number
-
-
setIntHeader
Deprecated.
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.
-
-
setIntHeader
Deprecated.
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.
-
-
-
-
getDateHeader
Deprecated.
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.
- Returns:
- the header value
- Throws:
ParseException - if there is no such header or the header value is not a formatted date
-
-
getDateHeader
Deprecated.
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.
- Returns:
- the header value or the
defaultValue if there is no such
header or the header value is not a formatted date
-
-
setDateHeader
Deprecated.
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
-
-
setDateHeader
Deprecated.
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
-
-
-
getContentLength
- Returns:
- the content length
- Throws:
NumberFormatException - if the message does not have the "Content-Length" header
or its value is not a number
-
getContentLength
- Returns:
- the content length or
defaultValue if this message does
not have the "Content-Length" header or its value is not
a number
-
-
-
getHost
Deprecated.
Use get(CharSequence, String) instead.
Returns the value of the "Host" header. If there is no such
header, the defaultValue is returned.
-
-
-
getDate
- Throws:
ParseException - if there is no such header or the header value is not a formatted date
-
getDate
Deprecated.
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.
-
-
-
-
set100ContinueExpected
Deprecated.
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.
-
isTransferEncodingChunked
- Parameters:
message - The message to check
- Returns:
- True if transfer encoding is chunked, otherwise false
-
removeTransferEncodingChunked
-
setTransferEncodingChunked
-
-
-
-
newEntity
Deprecated.
Use 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.
-
-
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
public abstract int getInt(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 search
defaultValue - 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
public abstract short getShort(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 search
defaultValue - 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
public abstract long getTimeMillis(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 search
defaultValue - 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
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 new 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.
- See Also:
-
-
contains
public abstract boolean contains(String name)
- See Also:
-
-
-
iteratorCharSequence
- Returns:
- Iterator over the name/value header pairs.
-
valueStringIterator
Equivalent to getAll(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 to name.
-
valueCharSequenceIterator
Equivalent to getAll(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 to name.
-
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 new 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.
-
-
add
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 in the cases
of Date and Calendar, which are formatted to the date
format defined in RFC2616.
- Parameters:
name - The name of the header being added
value - The value of the header being added
- Returns:
this
-
-
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 set
values - The values of the headers being set
- Returns:
this
-
add
Adds all header entries of the specified headers.
- Returns:
this
-
addInt
Add the name to value.
- Parameters:
name - The name to modify
value - The value
- Returns:
this
-
addShort
Add the name to value.
- Parameters:
name - The name to modify
value - The value
- Returns:
this
-
-
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 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.
- Parameters:
name - The name of the header being set
value - The value of the header being set
- Returns:
this
-
-
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 set
values - The values of the headers being set
- Returns:
this
-
set
Cleans the current header entries and copies all header entries of the specified headers.
- Returns:
this
-
setAll
- Parameters:
headers - The headers used to set(String, Object) values in this instance
- Returns:
this
-
setInt
Set the name to value. This will remove all previous values associated with name.
- Parameters:
name - The name to modify
value - The value
- Returns:
this
-
setShort
Set the name to value. This will remove all previous values associated with name.
- Parameters:
name - The name to modify
value - The value
- Returns:
this
-
-
remove
Removes the header with the specified name.
- Parameters:
name - The name of the header to remove
- Returns:
this
-
-
contains
public boolean contains(String name,
String value,
boolean ignoreCase)
- See Also:
-
-
containsValue
Returns 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.
- Parameters:
name - the name of the header to find
value - the value of the header to find
ignoreCase - true then a case insensitive compare is run to compare values.
otherwise a case sensitive compare is run to compare values.
-
getAsString
- 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
- Parameters:
name - the name of the header to retrieve
- Returns:
- a
List of header values or an empty List if no values are found.
-
-
contains
Returns 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.
- Parameters:
name - the name of the header to find
value - the value of the header to find
ignoreCase - true then a case insensitive compare is run to compare values.
otherwise a case sensitive compare is run to compare values.
-
-
|