GeezerVison is showing netty.io — DefaultHttpHeaders (Netty API Reference (4.1.141.Final))
Class DefaultHttpHeaders
-
-
-
Constructor Summary
Constructors
Modifier
Constructor
Description
Create a new, empty HTTP headers object.
protected
Create an HTTP headers object with the given name validator.
protected
Create an HTTP headers object with the given name and value validators.
protected
Create an HTTP headers object with the given name and value validators.
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.
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.
boolean
boolean
Returns a new List that contains all headers in this object.
boolean
Returns the value of a header with the specified name.
Returns the values of headers with the specified name
Returns the integer value of a header with the specified name.
int
Returns the integer value of a header with the specified name.
Returns the short value of a header with the specified name.
short
Returns the short value of a header with the specified name.
Returns the date value of a header with the specified name.
long
Returns the date value of a header with the specified name.
int
boolean
Checks if no header exists.
Returns a new Set that contains the names of all headers in this object.
Removes the header with the specified name.
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.
int
Returns the number of headers in this object.
Methods inherited from class HttpHeaders
addDateHeader, addDateHeader, addHeader, addHeader, addIntHeader, addIntHeader, clearHeaders, containsValue, encodeAscii, equalsIgnoreCase, get, getAllAsString, getAsString, getContentLength, getContentLength, getDate, getDate, getDateHeader, getDateHeader, getDateHeader, getDateHeader, getHeader, getHeader, getHeader, getHeader, getHost, getHost, getIntHeader, getIntHeader, getIntHeader, getIntHeader, is100ContinueExpected, isContentLengthSet, isKeepAlive, isTransferEncodingChunked, iteratorAsString, newEntity, removeHeader, removeHeader, removeTransferEncodingChunked, set100ContinueExpected, set100ContinueExpected, setAll, setContentLength, setDate, setDateHeader, setDateHeader, setDateHeader, setDateHeader, setHeader, setHeader, setHeader, setHeader, setHost, setHost, setIntHeader, setIntHeader, setIntHeader, setIntHeader, setKeepAlive, setTransferEncodingChunked, toString
Modifier and Type
Method
Description
static void
static void
static void
static void
static void
static void
static void
boolean
Returns true if a header with the name and value exists, false otherwise.
static void
static boolean
Returns the value of a header with the specified name.
static long
static long
static int
static int
static int
static int
static boolean
static boolean
static boolean
static boolean
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
static void
static void
static void
-
Constructor Details
-
DefaultHttpHeaders
public DefaultHttpHeaders()
Create a new, empty HTTP headers object.
Header names and values are validated as they are added, to ensure they are compliant with the HTTP protocol.
-
DefaultHttpHeaders
@Deprecated
public DefaultHttpHeaders(boolean validate)
Warning! Setting validate to false will mean that Netty won't
validate invalid input: '&' protect against user-supplied header values that are malicious.
This can leave your server implementation vulnerable to
CWE-113: Improper Neutralization of CRLF Sequences in HTTP Headers ('HTTP Response Splitting')
.
When disabling this validation, it is the responsibility of the caller to ensure that the values supplied
do not contain a non-url-escaped carriage return (CR) and/or line feed (LF) characters.
- Parameters:
validate - Should Netty validate header values to ensure they aren't malicious.
-
DefaultHttpHeaders
- Parameters:
validateValues - Should Netty validate header values to ensure they aren't malicious.
nameValidator - The DefaultHeaders.NameValidator to use, never
invalid @code
{@code null.
-
-
-
-
Method Details
-
-
add
Adds all header entries of the specified headers.
- Overrides:
add in class HttpHeaders
- Returns:
this
-
set
Cleans the current header entries and copies all header entries of the specified headers.
- Overrides:
set in class HttpHeaders
- Returns:
this
-
-
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.
- Overrides:
add in class HttpHeaders
- 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);
}
- Overrides:
add in class HttpHeaders
- Parameters:
name - The name of the headers being set
values - The values of the headers being set
- Returns:
this
-
addInt
Add the name to value.
- Specified by:
addInt in class HttpHeaders
- Parameters:
name - The name to modify
value - The value
- Returns:
this
-
addShort
Add the name to value.
- Specified by:
addShort in class HttpHeaders
- Parameters:
name - The name to modify
value - The value
- Returns:
this
-
-
remove
Removes the header with the specified name.
- Overrides:
remove in class HttpHeaders
- Parameters:
name - The name of the header to remove
- 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.
- Overrides:
set in class HttpHeaders
- 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);
}
- Overrides:
set in class HttpHeaders
- Parameters:
name - The name of the headers being set
values - The values of the headers being set
- Returns:
this
-
setInt
Set the name to value. This will remove all previous values associated with name.
- Specified by:
setInt in class HttpHeaders
- 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.
- Specified by:
setShort in class HttpHeaders
- Parameters:
name - The name to modify
value - The value
- Returns:
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.
- Overrides:
get in class HttpHeaders
- Parameters:
name - The name of the header to search
- Returns:
- The first header value or
null if there is no such header
- See Also:
-
-
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.
- Specified by:
getInt in class HttpHeaders
- 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.
- Specified by:
getInt in class HttpHeaders
- 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.
- Specified by:
getShort in class HttpHeaders
- 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 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.
- Specified by:
getShort in class HttpHeaders
- 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.
- Specified by:
getTimeMillis in class HttpHeaders
- 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 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.
- Specified by:
getTimeMillis in class HttpHeaders
- 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
- Overrides:
getAll in class HttpHeaders
- 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 HttpHeaders.iterator() instead, which has much less overhead.
- Specified by:
entries in class HttpHeaders
- See Also:
-
-
-
-
-
valueCharSequenceIterator
-
-
contains
Checks to see if there is a header with the specified name
- Overrides:
contains in class HttpHeaders
- Parameters:
name - The name of the header to search for
- Returns:
- True if at least one header is found
-
isEmpty
public boolean isEmpty()
Checks if no header exists.
- Specified by:
isEmpty in class HttpHeaders
-
size
public int size()
Returns the number of headers in this object.
- Specified by:
size in class HttpHeaders
-
-
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.
- Overrides:
contains in class HttpHeaders
- 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.
-
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 HttpHeaders.iterator() instead, which has much less overhead.
- Specified by:
names in class HttpHeaders
-
-
-
|