Skip to content

Commit ca6d30d

Browse files
fix: force gzip when no accept encoding header is sent and use identity if gzip is not sent (#28026)
Co-authored-by: Chris Breiding <[email protected]>
1 parent fd2a27d commit ca6d30d

File tree

4 files changed

+159
-20
lines changed

4 files changed

+159
-20
lines changed

cli/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33

44
_Released 10/25/2023 (PENDING)_
55

6+
**Bugfixes:**
7+
8+
- Fixed an issue with Accept Encoding headers by forcing gzip when no accept encoding header is sent and using identity if gzip is not sent. Fixes [#28025](https://github.com/cypress-io/cypress/issues/28025).
9+
610
**Dependency Updates:**
711

812
- Upgraded [`@babel/core`](https://www.npmjs.com/package/@babel/core) from `7.22.9` to `7.23.2` to address the [SNYK-JS-SEMVER-3247795](https://snyk.io/vuln/SNYK-JS-SEMVER-3247795) security vulnerability. Upgraded [`@babel/traverse`](https://www.npmjs.com/package/@babel/traverse) from `7.22.8` to `7.23.2` to address the [SNYK-JS-BABELTRAVERSE-5962462](https://snyk.io/vuln/SNYK-JS-BABELTRAVERSE-5962462) security vulnerability. Upgraded [`react-docgen`](https://www.npmjs.com/package/react-docgen) from `6.0.0-alpha.3` to `6.0.4` to address the [SNYK-JS-BABELTRAVERSE-5962462](https://snyk.io/vuln/SNYK-JS-BABELTRAVERSE-5962462) security vulnerability. Addressed in [#28063](https://github.com/cypress-io/cypress/pull/28063).

packages/proxy/lib/http/request-middleware.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ const EndRequestsToBlockedHosts: RequestMiddleware = function () {
348348
const StripUnsupportedAcceptEncoding: RequestMiddleware = function () {
349349
const span = telemetry.startSpan({ name: 'strip:unsupported:accept:encoding', parentSpan: this.reqMiddlewareSpan, isVerbose })
350350

351-
// Cypress can only support plaintext or gzip, so make sure we don't request anything else
351+
// Cypress can only support plaintext or gzip, so make sure we don't request anything else, by either filtering down to `gzip` or explicitly specifying `identity`
352352
const acceptEncoding = this.req.headers['accept-encoding']
353353

354354
span?.setAttributes({
@@ -365,8 +365,12 @@ const StripUnsupportedAcceptEncoding: RequestMiddleware = function () {
365365
if (doesAcceptHeadingIncludeGzip) {
366366
this.req.headers['accept-encoding'] = 'gzip'
367367
} else {
368-
delete this.req.headers['accept-encoding']
368+
this.req.headers['accept-encoding'] = 'identity'
369369
}
370+
} else {
371+
// If there is no accept-encoding header, it means to accept everything (https://www.rfc-editor.org/rfc/rfc9110#name-accept-encoding).
372+
// In that case, we want to explicitly filter that down to `gzip` and identity
373+
this.req.headers['accept-encoding'] = 'gzip,identity'
370374
}
371375

372376
span?.end()

0 commit comments

Comments
 (0)