Class Http2FlowControlBodies

java.lang.Object
org.mockserver.test.Http2FlowControlBodies

public final class Http2FlowControlBodies extends Object
Size-parameterised, deterministic response bodies for HTTP/2 integration tests.

Why this exists. Four HTTP/2 defects (GitHub #2641, #2667, #2669, #2683) all shipped while every HTTP/2 test was green, for one structural reason: every HTTP/2 test used a response body smaller than the 65535-byte flow-control window — including the one literally named shouldForwardHttp2RequestWithLargeBodyViaConnectProxy at 50,000 bytes. A body that fits in the peer's first window is delivered without any WINDOW_UPDATE, so the writePendingBytes() flush those defects live in is never exercised, and the whole family of bugs — whose failure mode is a silent hang, not a wrong answer — is invisible. See docs/code/netty-pipeline.md ("Testing convention: an HTTP/2 test MUST use a response body larger than the flow-control window").

What this gives you. A named set of sizes (Http2FlowControlBodies.Size.SMALL, Http2FlowControlBodies.Size.OVER_WINDOW, Http2FlowControlBodies.Size.LARGE) so a new HTTP/2 test crosses the window by construction — the author picks OVER_WINDOW without having to know the 65,535-byte history or type a magic number. Bodies are deterministic and distinguishable: the content is stamped throughout with a caller-supplied marker, so a mis-routed body (delivered on the wrong h2 stream) or a truncated body fails an equality assertion, not merely a length check.

Lives in mockserver-testing (package org.mockserver.test) rather than in a single test tree because it is a compile-scope dependency of mockserver-integration-testing and a test dependency of mockserver-netty, mockserver-war and the rest — so every module with HTTP/2 tests can reach it. It has no dependency beyond the JDK.

  • Field Details

    • FLOW_CONTROL_WINDOW_BYTES

      public static final int FLOW_CONTROL_WINDOW_BYTES
      The HTTP/2 initial flow-control window in bytes, per RFC 7540 / 9113 §6.9.2. A response at or under this size is delivered inside the peer's first window and never drives a WINDOW_UPDATE, so it cannot exercise the flow-control flush. This is the threshold every Http2FlowControlBodies.Size.OVER_WINDOW body must clear.
      See Also:
  • Method Details

    • body

      public static String body(Http2FlowControlBodies.Size size, String marker)
      A deterministic body of exactly size bytes whose filler is stamped throughout with marker, so a mis-routed or truncated body cannot equal the expected one anywhere along its length. Give each concurrently-multiplexed stream a distinct marker so a body delivered on the wrong stream fails an equality assertion.
      Parameters:
      size - the named body size (use Http2FlowControlBodies.Size.OVER_WINDOW for any real HTTP/2 assertion)
      marker - a short label stamped throughout the body; must be non-empty
      Returns:
      a String of exactly Http2FlowControlBodies.Size.bytes() characters