Provides a unified access to HTTP headers, giving the ability to decode or encode Header
instances for various headers.
Implementations can rely on multiple HeaderCodec
to decode and encode headers based on the header name.
- Since:
- 1.0
- Author:
- Jeremy Kuhn
- See Also:
-
Method Summary
Modifier and TypeMethodDescription<T extends Header>
TDecodes the specified header fieldByteBuf
as defined by RFC 7230 Section 3.2 using the specified charset.<T extends Header>
TDecodes the specified header field as defined by RFC 7230 Section 3.2.<T extends Header>
TDecodes the specified raw valueByteBuf
for the specified header name using the specified charset.<T extends Header>
TDecodes the specified raw header value for the specified header name.encode
(T header) Encodes the specified header as a string.<T extends Header>
voidEncodes the specified header in the specifiedByteBuffer
using the specified charset.encodeValue
(T header) Encodes the value of the specified header as a string.<T extends Header>
voidencodeValue
(T header, ByteBuf buffer, Charset charset) Encodes the value of the specified header in the specifiedByteBuffer
using the specified charset.static boolean
isB64Token
(String value) Determines whether the specified value is a valid header base64 token as defined by RFC 7235 Section 2.1.static boolean
isB64TokenCharacter
(char character) Determines whether the specified character is a valid header base64 character as defined by RFC 7235 Section 2.1.static boolean
Determines whether the specified value is a valid header content as defined by RFC 7230 Section 3.2.6 and RFC 5234 Appendix B.1static boolean
isContentCharacter
(char character) Determines whether the specified character is a valid header content character as defined by RFC 7230 Section 3.2.6 and RFC 5234 Appendix B.1static boolean
Determines whether the specified value is a valid header token as defined by RFC 7230 Section 3.2.6.static boolean
isTokenCharacter
(char character) Determines whether the specified character is a valid header token character as defined by RFC 7230 Section 3.2.6.
-
Method Details
-
decode
Decodes the specified header field as defined by RFC 7230 Section 3.2.
- Type Parameters:
T
- the decoded header type- Parameters:
header
- a raw header field- Returns:
- a decoded header instance
-
decode
Decodes the specified header field
ByteBuf
as defined by RFC 7230 Section 3.2 using the specified charset.- Type Parameters:
T
- the decoded header type- Parameters:
buffer
- a raw header fieldcharset
- the charset to use for decoding- Returns:
- a decoded header instance
-
decode
Decodes the specified raw header value for the specified header name.
- Type Parameters:
T
- the decoded header type- Parameters:
name
- a header namevalue
- a header raw value- Returns:
- a decoded header instance
-
decode
Decodes the specified raw value
ByteBuf
for the specified header name using the specified charset.- Type Parameters:
T
- the decoded header type- Parameters:
name
- a header namebuffer
- a header raw valuecharset
- the charset to use for decoding- Returns:
- a decoded header instance
-
encode
Encodes the specified header as a string.
The resulting value is a header field as defined by RFC 7230 Section 3.2.
- Type Parameters:
T
- the encoded header type- Parameters:
header
- the header to encode- Returns:
- the encoded header string
-
encode
Encodes the specified header in the specified
ByteBuffer
using the specified charset.The resulting value is a header field as defined by RFC 7230 Section 3.2.
- Type Parameters:
T
- the encoded header type- Parameters:
header
- the header to encodebuffer
- the destination byte buffercharset
- the charset to use for encoding
-
encodeValue
Encodes the value of the specified header as a string.
The resulting value corresponds to the header field value as defined by RFC 7230 Section 3.2.
- Type Parameters:
T
- the encoded header type- Parameters:
header
- the header to encode- Returns:
- the encoded header value
-
encodeValue
Encodes the value of the specified header in the specified
ByteBuffer
using the specified charset.The resulting value corresponds to the header field value as defined by RFC 7230 Section 3.2.
- Type Parameters:
T
- the encoded header type- Parameters:
header
- the header to encodebuffer
- the destination byte buffercharset
- the charset to use for encoding
-
isTokenCharacter
static boolean isTokenCharacter(char character) Determines whether the specified character is a valid header token character as defined by RFC 7230 Section 3.2.6.
- Parameters:
character
- the character to test- Returns:
- true if the character is a header token character, false otherwise
-
isToken
Determines whether the specified value is a valid header token as defined by RFC 7230 Section 3.2.6.
- Parameters:
value
- the value to test- Returns:
- true if the value is a header token, false otherwise
-
isB64TokenCharacter
static boolean isB64TokenCharacter(char character) Determines whether the specified character is a valid header base64 character as defined by RFC 7235 Section 2.1.
- Parameters:
character
- the character to test- Returns:
- true if the character is a header token68 character, false otherwise
-
isB64Token
Determines whether the specified value is a valid header base64 token as defined by RFC 7235 Section 2.1.
- Parameters:
value
- the value to test- Returns:
- true if the value is a header base64 token, false otherwise
-
isContentCharacter
static boolean isContentCharacter(char character) Determines whether the specified character is a valid header content character as defined by RFC 7230 Section 3.2.6 and RFC 5234 Appendix B.1
- Parameters:
character
- the character to test- Returns:
- true if the character is a header content character, false otherwise
-
isContent
Determines whether the specified value is a valid header content as defined by RFC 7230 Section 3.2.6 and RFC 5234 Appendix B.1
- Parameters:
value
- the value to test- Returns:
- true if the value is a header content, false otherwise
-