feat(http2): inflate gzip response bodies #12306
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/12306"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by edubox on 2026-10-28T08:38:15Z.
What
sceHttp2SetInflateGZIPEnabledthrew for a nonzero argument. It now stores the flag. When the flag is set and the response carriescontent-encoding: gzip, the transport waits for END_STREAM, inflates the complete body, and only then serves it throughsceHttp2ReadDataandsceHttp2GetResponseContentLength, which report the inflated length. The transport does not add or inspectAccept-Encoding: the guest supplies that request header, and a gzip response is inflated while the option is enabled even if the guest did not request it.The vendored zlib is built with
NO_GZIP, so the transport parses the gzip header and trailer itself and inflates the payload as raw deflate; the CRC32 and ISIZE fields are verified. The initializedz_streamis released on every exit. Other encodings are not inflated. A malformed or truncated stream, concatenated members and an inflated body over 64 MiB throw. The console's header rewriting (Content-Encoding and Content-Length) is unverified and documented in the debt entry.Tested
Linux (CachyOS), GCC 16.2.1, Release.
guest_http2_transportaddsGzip,GzipSplitandGzipTruncatedserver modes: with the flag set,sceHttp2ReadDatareturnsresponse bodyandsceHttp2GetResponseContentLengthreports 13;GzipSplitsends the first 8 DATA bytes, defers the rest and reads in 3-byte pieces;GzipTruncateddrops four trailer bytes and the read path throws; with the flag clear, the 33-byte compressed stream is returned unchanged.guest_http2*passes. Title: PPSA02195 enables inflate on its template on a tree with other local changes.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Transport.cppand the debt file; keep both sides. The same files overlap with #11134, #11470, #11611 and #11950, none of which implements gzip)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-28T08:48:16Z.
Review: CHANGES_REQUESTED
I found a cleanup issue on the malformed-response path. After
inflateInit2succeeds, everyRequirefailure in the header parser, inflate loop, or trailer validation exitsInflateGzipby exception beforeinflateEndruns. A server that repeatedly returns malformed gzip data can therefore retain zlib state per failed request. Please guard the initializedz_streamwith RAII (or equivalent cleanup on all exits) and add a malformed/truncated or bad-trailer regression that exercises the failure path. The current valid-gzip/passthrough test does not cover this. Windows CI and conventions pass; the focused transport tests are reported by the author on Linux, while hosted Linux is skipped.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-28T09:11:14Z.
Review: CHANGES_REQUESTED
The head
4f58a9e35cis a rebase with no code changes, so the correctness gap remains:InflateGzip()is called only after END_STREAM, whileRequest::Readcan return and drain DATA before that point. A split or >65,535-byte gzip response can therefore expose compressed bytes or pass only the tail to the inflater. Please buffer the complete encoded response before reads when inflation is enabled, or implement streaming inflate, and add a regression where DATA arrives in multiple reads before END_STREAM.Also ensure
inflateEndruns on every error path and add an error-path test (malformed/truncated input or a bad trailer is sufficient to exercise cleanup). The existing valid-gzip/passthrough test does not cover the leak. Please state whether you expectAccept-Encodingto come from the guest; as written, the response is inflated whenever the option is enabled and the server answers gzip, whether or not the guest requested it. Author-reported Linux tests and conventions do not cover these cases, and hosted jobs are queued.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-28T11:38:13Z.
Review: CHANGES_REQUESTED
Thanks, the END_STREAM wait, the RAII
z_streamguard and the flow-control consume cover the earlier review points;GzipSplit,GzipLargeandGzipTruncatedpin the new behaviour.One point is still open (raised by @oneandonlydean, not addressed on this head):
core/libs/tests/GuestHttp2Transport.cpp:415-501: the debt entry says a bad checksum, concatenated gzip members and the 64 MiB cap throw, but only the truncated stream is tested. Please add a server mode for a wrong CRC32 or ISIZE and one for two concatenated members, each asserting the read throws (Transport.cpp:365-371). The cap can stay untested if you drop it from the claim, or lower it behind a test constant.Once those are in this is ready; the
Transport.cppand debt-file overlap with #12305 is mechanical and we will handle it when merging.