Skip to content

Read streamed request bodies only when Replay needs them - #35

Merged
mattt merged 4 commits into
mainfrom
mattt/stream-unneeded-bodies
Nov 21, 2026
Merged

mattt merged 4 commits into
mainfrom
mattt/stream-unneeded-bodies

Conversation

@mattt

@mattt mattt commented Nov 18, 2026

Copy link
Copy Markdown
Owner

This PR makes Replay read a request's body stream only when a .body or .custom matcher runs or the request is recorded, so other requests, including live playback without recording, go to the network with their stream. When Replay does read the body, cancelling the request stops the read, and a body over the new maximumRequestBodySize setting on PlaybackConfiguration and CaptureConfiguration (10 MiB by default) fails the request with URLError(.dataLengthExceedsMaximum). Streams that cannot be read in full still fail with URLError(.requestBodyStreamExhausted), as in #32.

Playback reads a request's body stream only when a .body or .custom matcher runs or recording is on; otherwise the request keeps its stream. Reads check for cancellation between chunks and stop at maximumRequestBodySize (10 MiB by default), failing with URLError(.dataLengthExceedsMaximum).
@mattt
mattt merged commit 958b9ab into main Nov 21, 2026
16 checks passed
@mattt
mattt deleted the mattt/stream-unneeded-bodies branch November 21, 2026 11:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant