Class H1ProtocolConfigBuilder

java.lang.Object
io.servicetalk.http.netty.H1ProtocolConfigBuilder

public final class H1ProtocolConfigBuilder extends Object
Builder for H1ProtocolConfig.
See Also:
  • Method Details

    • headersFactory

      public H1ProtocolConfigBuilder headersFactory(HttpHeadersFactory headersFactory)
      Sets the HttpHeadersFactory to be used for creating HttpHeaders when decoding HTTP messages.
      Parameters:
      headersFactory - HttpHeadersFactory to be used for creating HttpHeaders when decoding HTTP messages
      Returns:
      this
    • maxPipelinedRequests

      public H1ProtocolConfigBuilder maxPipelinedRequests(int maxPipelinedRequests)
      Sets the maximum number of pipelined HTTP requests to queue up.

      Anything above this value will be rejected, 1 means pipelining is disabled and requests/responses are processed sequentially. Default value is 1.

      Note: reserved connections will not be restricted by this setting.

      Parameters:
      maxPipelinedRequests - maximum number of pipelined requests to queue up
      Returns:
      this
    • maxStartLineLength

      public H1ProtocolConfigBuilder maxStartLineLength(int maxStartLineLength)
      Sets the maximum length (size in bytes) of the HTTP start line for an HTTP message.

      Default value is 8192 bytes.

      Note: a decoder will close the connection with TooLongFrameException if the start line exceeds this value, including CRLF delimiter at the end.

      Parameters:
      maxStartLineLength - maximum length (size in bytes) of the HTTP start line for an HTTP message
      Returns:
      this
    • maxTotalHeaderFieldsLength

      public H1ProtocolConfigBuilder maxTotalHeaderFieldsLength(int maxTotalHeaderFieldsLength)
      Sets the maximum total allowed length (size in bytes) of the HTTP start line and all header fields, or all trailer fields.

      This limit protects against memory exhaustion attacks where an attacker sends many small headers or trailers that individually pass field validation but collectively consume excessive memory.

      Note: a decoder will close the connection with TooLongFrameException if the total headers or trailers block size exceeds this value, including CRLF delimiter at the end of each line.

      This is an HTTP/1.x equivalent of HTTP/2's SETTINGS_MAX_HEADER_LIST_SIZE that can be configured via Http2Settings.maxHeaderListSize() for H2ProtocolConfigBuilder.initialSettings(Http2Settings).

      The default value is 32768 bytes. Users who unexpectedly hit the default limit can temporarily (until they can adjust the limit via this method) set io.servicetalk.http.netty.temporaryDefaultMaxTotalHeaderFieldsLength to a new value. However, this is a temporary property that will be removed in the future releases.

      Parameters:
      maxTotalHeaderFieldsLength - maximum total allowed length (size in bytes) of the start line and all headers, or all trailers
      Returns:
      this
      See Also:
    • maxHeaderFieldLength

      public H1ProtocolConfigBuilder maxHeaderFieldLength(int maxHeaderFieldLength)
      Sets the maximum length (size in bytes) of an individual HTTP header field or trailer field to parse.

      Default value is 16384 bytes.

      Note: a decoder will close the connection with TooLongFrameException if the length of a header or trailer field exceeds this value, including CRLF delimiter at the end.

      Parameters:
      maxHeaderFieldLength - maximum length (size in bytes) of an individual HTTP header field or trailer field to parse
      Returns:
      this
      See Also:
    • headersEncodedSizeEstimate

      public H1ProtocolConfigBuilder headersEncodedSizeEstimate(int headersEncodedSizeEstimate)
      Sets the value used to calculate an exponential moving average of the encoded size of the HTTP start line and header fields for a guess for future buffer allocations.
      Parameters:
      headersEncodedSizeEstimate - value used to calculate an exponential moving average of the encoded size of the HTTP start line and header fields
      Returns:
      this
    • trailersEncodedSizeEstimate

      public H1ProtocolConfigBuilder trailersEncodedSizeEstimate(int trailersEncodedSizeEstimate)
      Sets the value used to calculate an exponential moving average of the encoded size of the HTTP trailer fields for a guess for future buffer allocations.
      Parameters:
      trailersEncodedSizeEstimate - value used to calculate an exponential moving average of the encoded size of the HTTP trailer fields
      Returns:
      this
    • specExceptions

      public H1ProtocolConfigBuilder specExceptions(H1SpecExceptions specExceptions)
      Sets additional exceptions for HTTP/1.1 specification.
      Parameters:
      specExceptions - exceptions for HTTP/1.1 specification
      Returns:
      this
    • build

      public H1ProtocolConfig build()
      Returns:
      a new H1ProtocolConfig