Class GenericHeaderCodec<A extends Header,B extends HeaderBuilder<A,B>>

java.lang.Object
io.inverno.mod.http.base.header.AbstractHeaderCodec<A,B>
io.inverno.mod.http.base.internal.header.GenericHeaderCodec<A,B>
Type Parameters:
A - the header type encoded/decoded by the codec
B - the header builder type
All Implemented Interfaces:
HeaderCodec<A>

public class GenericHeaderCodec<A extends Header,B extends HeaderBuilder<A,B>> extends AbstractHeaderCodec<A,B>

Genric HTTP HeaderCodec implementation.

Since:
1.0
Author:
Jeremy Kuhn
See Also:
  • Constructor Details

    • GenericHeaderCodec

      protected GenericHeaderCodec(Supplier<B> builderSupplier, Set<String> supportedHeaderNames)

      Creates a generic HTTP header codec.

      Parameters:
      builderSupplier - a supplier to create header builder instances when decoding a header
      supportedHeaderNames - the list of header names supported by the codec
  • Method Details

    • decode

      public A decode(String name, String value)
      Description copied from interface: HeaderCodec

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

      Parameters:
      name - a header name
      value - a header raw value
      Returns:
      a decoded header instance
    • decode

      public A decode(String name, io.netty.buffer.ByteBuf buffer, Charset charset)
      Description copied from interface: HeaderCodec

      Decodes the specified raw value ByteBuf for the specified header name using the specified charset.

      Parameters:
      name - a header name
      buffer - a header raw value
      charset - the charset to use for decoding
      Returns:
      a decoded header instance
    • encode

      public String encode(A headerField)
      Description copied from interface: HeaderCodec

      Encodes the specified header as a string.

      The resulting value is a header field as defined by RFC 7230 Section 3.2.

      Parameters:
      headerField - the header to encode
      Returns:
      the encoded header
    • encodeValue

      public String encodeValue(A headerField)
      Description copied from interface: HeaderCodec

      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.

      Parameters:
      headerField - the header to encode
      Returns:
      the encoded header value