[testmode] Fix compressed HTTP responses with test proxy (#100805)
## Summary Fix compressed responses received by Node HTTP clients when `experimental.testProxy` is enabled. Requests outside a test context and proxy `continue` responses now use native HTTP passthrough, preserving the original compressed bytes and headers. Normalize stale `Content-Encoding` and `Content-Length` headers when serializing fetched responses with supported compression encodings, including cloned fetch responses. Preserve explicitly constructed mock responses as supplied, including deliberately compressed bytes. Handlers that construct a response with a modified body must update its headers themselves. Preserve bodyless responses such as HEAD so their representation metadata remains available. Add regression coverage for chunked responses and compressed bodies whose decoded length is shorter or longer than the upstream content length, across native passthrough, proxy continue, fetched responses, and modified responses. Also cover explicitly compressed mocks, fetched-response clones, unsupported encodings, and HEAD metadata. ## Verification - All 36 testmode integration tests passed in development mode with webpack, using the published native binding because the local native build has an incompatible lockfile API. - Confirmed the standalone gzip reproduction fails against the unchanged build and passes with native passthrough. <!-- NEXT_JS_LLM -->
Showing
Please
register
or
sign in
to comment