Skip to content

fix: Sync-flush gzip so flushed stream data reaches the client - #134

Merged
thced merged 1 commit into
masterfrom
fix/gzip-streaming-flush
Oct 18, 2026
Merged

thced merged 1 commit into
masterfrom
fix/gzip-streaming-flush

Conversation

@thced

@thced thced commented Oct 18, 2026

Copy link
Copy Markdown
Contributor

GzipCoding.encode returned a GZIPOutputStream without syncFlush, so flush() only flushed the underlying socket and left everything written so far inside the deflater. A streamed response (e.g. application/x-ndjson) that flushed an event delivered only the 10-byte gzip header to a client sending Accept-Encoding: gzip, until the deflater's buffer filled or the stream closed. Progressive and long-poll streams stalled.

Create the GZIPOutputStream with syncFlush so a flush writes everything so far in a decodable form. Whole bodies are coded without a flush, so they pay nothing for it. Document the flush contract on ContentCoding.encode and in the README.

Add GzipCodingTest covering flush output and a closed-stream round trip, and a GzipIT test that a flushed event of a gzipped stream reaches the client before the stream ends.

GzipCoding.encode returned a GZIPOutputStream without syncFlush, so
flush() only flushed the underlying socket and left everything written
so far inside the deflater. A streamed response (e.g. application/x-ndjson)
that flushed an event delivered only the 10-byte gzip header to a client
sending Accept-Encoding: gzip, until the deflater's buffer filled or the
stream closed. Progressive and long-poll streams stalled.

Create the GZIPOutputStream with syncFlush so a flush writes everything
so far in a decodable form. Whole bodies are coded without a flush, so
they pay nothing for it. Document the flush contract on
ContentCoding.encode and in the README.

Add GzipCodingTest covering flush output and a closed-stream round trip,
and a GzipIT test that a flushed event of a gzipped stream reaches the
client before the stream ends.
@sonarqubecloud

Copy link
Copy Markdown

@thced
thced merged commit d205721 into master Oct 18, 2026
5 checks passed
@thced
thced deleted the fix/gzip-streaming-flush branch October 18, 2026 08: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.

2 participants