Class Http2Options.Builder

java.lang.Object
org.microproxy.Http2Options.Builder
Enclosing class:
Http2Options

public static final class Http2Options.Builder extends Object
Builds Http2Options.
  • Method Details

    • maxConcurrentStreams

      public Http2Options.Builder maxConcurrentStreams(int n)
      Streams a client may have open at once (default 100). Each runs its own exchange, with its own server connection; streams beyond the limit are refused with REFUSED_STREAM, which clients retry.
      Parameters:
      n - the maximum streams open at once
      Returns:
      this builder
    • initialWindowSize

      public Http2Options.Builder initialWindowSize(int bytes)
      The flow-control window of each stream's request body (default 256 KiB): the most the proxy buffers for a stream whose body it has not read yet.
      Parameters:
      bytes - the stream receive window size, at least 65535 bytes
      Returns:
      this builder
    • connectionWindowSize

      public Http2Options.Builder connectionWindowSize(int bytes)
      The connection's flow-control window (default 1 MiB): the most the proxy buffers for all of a connection's streams together.
      Parameters:
      bytes - the connection receive window size, at least 65535 bytes
      Returns:
      this builder
    • maxHeaderListSize

      public Http2Options.Builder maxHeaderListSize(int bytes)
      The largest request header section, counted as HTTP/2 counts it (names and values plus 32 octets per field); larger requests have their stream reset. 0 (the default) derives it from the HTTP/1 limits: withMaxHeaderSize plus withMaxInitialLineLength.
      Parameters:
      bytes - the maximum header list size, or zero to derive it from HTTP/1 limits
      Returns:
      this builder
    • settingsAckTimeout

      public Http2Options.Builder settingsAckTimeout(Duration timeout)
      How long the client may take to acknowledge the proxy's SETTINGS (default 10 s) before GOAWAY SETTINGS_TIMEOUT.
      Parameters:
      timeout - the maximum wait for a SETTINGS acknowledgement
      Returns:
      this builder
    • rateWindow

      public Http2Options.Builder rateWindow(Duration window)
      The window the rate limits below count frames in (default 10 s).
      Parameters:
      window - the frame-counting window duration
      Returns:
      this builder
    • maxRapidResets

      public Http2Options.Builder maxRapidResets(int n)
      Streams the client may reset before their response completes, or open past the concurrency limit, per window (default 100), against the Rapid Reset attack (CVE-2023-44487); more is GOAWAY ENHANCE_YOUR_CALM.
      Parameters:
      n - the maximum rapid resets per window
      Returns:
      this builder
    • maxPings

      public Http2Options.Builder maxPings(int n)
      PING frames per window (default 100); more is GOAWAY ENHANCE_YOUR_CALM.
      Parameters:
      n - the maximum PING frames per window
      Returns:
      this builder
    • maxSettings

      public Http2Options.Builder maxSettings(int n)
      SETTINGS frames per window (default 100); more is GOAWAY ENHANCE_YOUR_CALM.
      Parameters:
      n - the maximum SETTINGS frames per window
      Returns:
      this builder
    • maxResets

      public Http2Options.Builder maxResets(int n)
      RST_STREAM and PRIORITY frames per window (default 1000); more is GOAWAY ENHANCE_YOUR_CALM.
      Parameters:
      n - the maximum RST_STREAM and PRIORITY frames per window
      Returns:
      this builder
    • maxWindowUpdates

      public Http2Options.Builder maxWindowUpdates(int n)
      WINDOW_UPDATE frames per window (default 10000); more is GOAWAY ENHANCE_YOUR_CALM.
      Parameters:
      n - the maximum WINDOW_UPDATE frames per window
      Returns:
      this builder
    • maxEmptyFrames

      public Http2Options.Builder maxEmptyFrames(int n)
      Frames that carry nothing, DATA frames with no data and no END_STREAM, per window (default 1000); more is GOAWAY ENHANCE_YOUR_CALM.
      Parameters:
      n - the maximum empty frames per window
      Returns:
      this builder
    • coalesceConnections

      public Http2Options.Builder coalesceConnections(boolean coalesce)
      Lets the proxy's HTTP/2 connections to servers (HttpProxyServerBootstrap.withHttp2Upstream(boolean)) carry requests for other server names than the one each was made for, as RFC 9113 section 9.1.1 allows (default off). A request for b.example.com may then take a stream on the connection made for a.example.com when the certificate that server presented is valid for b.example.com, and either b.example.com resolves (with the proxy's own resolver) to the address the connection went to, or the server named it in an ORIGIN frame (RFC 8336).

      Connections are never coalesced across routes (direct, or through which chained proxy), MITM managers, client connections whose connections are private, or TLS settings: the context the MITM manager gives each name must be the same, a manager that configures server sockets itself keeps every connection to its own name, and a connection on which the proxy presented a client certificate serves no other name. A request that a server answers 421 Misdirected Request on a coalesced connection is sent again on a connection of its own when it can be (no body, a buffered one, or one not read yet), and that name is not coalesced onto that connection again.

      Parameters:
      coalesce - true to coalesce connections to servers
      Returns:
      this builder
    • build

      public Http2Options build()
      Creates the configured HTTP/2 limits.
      Returns:
      the configured HTTP/2 limits