Skip to main content
Experimental Crate: codec

seleniumbase_rs_codec::h2_spec describes the start of an HTTP/2 connection that a client should reproduce: the SETTINGS entries and their order, the connection WINDOW_UPDATE, the PRIORITY frames, the priority fields of the first HEADERS frame, and the order of the pseudo-headers. An H2Spec is built from bytes captured from a real client (from_capture, from_preface), from an Akamai fingerprint string (from_akamai), or by overlaying such a string on a measured base (with_akamai).

Recording a capture and judging it are separate steps. from_preface records whatever the client sent, GREASE settings included. check_reproducible then says whether the wreq HTTP/2 stack can send it, before any client exists. What the stack cannot emit, as of wreq-proto 0.2.6:

  • SETTINGS other than ids 1 to 6, 8 and 9 (experimental and GREASE settings);
  • a SETTINGS id twice (the stack’s order builder drops the second silently);
  • leaving out SETTINGS_INITIAL_WINDOW_SIZE, which the stack always sends;
  • two PRIORITY frames for one stream, or one for stream 0 (both are dropped silently).

H2Spec#

struct

A whole HTTP/2 profile: what a client sends before and in its first request. Http2Spec is the same type under the name the design plan uses; it is the type of Emulation::http2. Re-exported at the crate root as H2Spec.

settingsVec<(u16, u32)>#

SETTINGS entries (id, value) in wire order.

window_updateu32#

The connection-level WINDOW_UPDATE increment; 0 means no frame.

priority_framesVec<PriorityFrame>#

PRIORITY frames sent before the first request, in order.

Default: "[]"

headers_priorityOption<HeadersPriority>#

The priority fields of the first HEADERS frame, when the client sends them.

pseudo_order[Pseudo; 4]#

The order of the request pseudo-headers.

initial_stream_idOption<u32>#

The stream id of the first request, when it is not the usual 1.

Constructors#

method
from_prefacemethod#

Records a captured connection start; nothing is judged. PseudoOrder when the request does not carry the four pseudo-headers exactly once and before its other headers.

from_capturemethod#

Reads a captured connection start from raw client bytes. Incomplete when the bytes end before the first request is complete, Capture when they are not a valid client start.

from_akamaimethod#

A spec from an Akamai fingerprint alone, checked to be sendable. The string says nothing about the priority fields of HEADERS, so none are set. The first request’s stream id is placed after the streams the PRIORITY frames name.

with_akamaimethod#

Overlays an Akamai fingerprint on this spec. The string replaces the SETTINGS, the connection window, the PRIORITY frames and the pseudo-header order, and the first request’s stream id is recomputed to come after the streams the PRIORITY frames name. What the string does not carry, the HEADERS priority fields, is kept from this spec. The result is checked.

Other methods#

method
  • check_reproducible: checks that the wreq HTTP/2 stack can send exactly this spec, and returns the first problem found, naming the setting, frame or field. SETTINGS values are held to the ranges of RFC 9113 section 6.5.2, RFC 8441 and RFC 9218; a PRIORITY frame must be on an odd client stream below 2^31, not depend on itself, and have a weight of 1 to 256; the initial stream id must be odd and below 2^31.
  • akamai: the Akamai fingerprint of this spec.
  • setting: the value of the SETTINGS entry with this id, when there is one.
  • without_unsupported_settings: this spec without the SETTINGS the stack cannot send, and the entries removed. For measured specs that include a GREASE setting, the dropped entries are the known gap between the capture and what a client can reproduce.

SpecError#

enum

Why an HTTP/2 spec cannot be built or cannot be sent.

SpecErrorenum#

setting_id#

mod

The SETTINGS identifiers of RFC 9113 section 6.5.2, RFC 8441 and RFC 9218.

Constants#

const

The SETTINGS ids the wreq HTTP/2 stack can send; the ids it sends whatever it is configured with (read from wreq-proto 0.2.6: Http2Options::initial_window_size is always passed on, and the capability probe of the client package is the final authority); the connection flow-control window before any WINDOW_UPDATE; the largest connection increment (the window may not pass 2^31 - 1); the legal range of SETTINGS_MAX_FRAME_SIZE; and the most PRIORITY frames a spec may carry (64).