Interface HeaderService


public interface HeaderService

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 Details

    • decode

      <T extends Header> T decode(String header)

      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

      <T extends Header> T decode(ByteBuf buffer, Charset charset)

      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 field
      charset - the charset to use for decoding
      Returns:
      a decoded header instance
    • decode

      <T extends Header> T decode(String name, String value)

      Decodes the specified raw header value for the specified header name.

      Type Parameters:
      T - the decoded header type
      Parameters:
      name - a header name
      value - a header raw value
      Returns:
      a decoded header instance
    • decode

      <T extends Header> T decode(String name, ByteBuf buffer, Charset charset)

      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 name
      buffer - a header raw value
      charset - the charset to use for decoding
      Returns:
      a decoded header instance
    • encode

      <T extends Header> String encode(T header)

      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

      <T extends Header> void encode(T header, ByteBuf buffer, Charset charset)

      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 encode
      buffer - the destination byte buffer
      charset - the charset to use for encoding
    • encodeValue

      <T extends Header> String encodeValue(T header)

      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

      <T extends Header> void encodeValue(T header, ByteBuf buffer, Charset charset)

      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 encode
      buffer - the destination byte buffer
      charset - 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

      static boolean isToken(String value)

      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

      static boolean isB64Token(String value)

      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

      static boolean isContent(String value)

      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