Skip to content

Commit

Permalink
fix: force gzip when no accept encoding header is sent and use identi…
Browse files Browse the repository at this point in the history
…ty if gzip is not sent (#28026)

Co-authored-by: Chris Breiding <chrisbreiding@users.noreply.github.com>
  • Loading branch information
ryanthemanuel and chrisbreiding committed Oct 17, 2023
1 parent fd2a27d commit ca6d30d
Show file tree
Hide file tree
Showing 4 changed files with 159 additions and 20 deletions.
4 changes: 4 additions & 0 deletions cli/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@

_Released 10/25/2023 (PENDING)_

**Bugfixes:**

- 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).

**Dependency Updates:**

- 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).
Expand Down
8 changes: 6 additions & 2 deletions packages/proxy/lib/http/request-middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ const EndRequestsToBlockedHosts: RequestMiddleware = function () {
const StripUnsupportedAcceptEncoding: RequestMiddleware = function () {
const span = telemetry.startSpan({ name: 'strip:unsupported:accept:encoding', parentSpan: this.reqMiddlewareSpan, isVerbose })

// Cypress can only support plaintext or gzip, so make sure we don't request anything else
// 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`
const acceptEncoding = this.req.headers['accept-encoding']

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

span?.end()
Expand Down

4 comments on commit ca6d30d

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on ca6d30d Oct 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the linux arm64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/13.3.2/linux-arm64/develop-ca6d30d7bf1811dda32c389bdb99aaeb975701c0/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on ca6d30d Oct 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the linux x64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/13.3.2/linux-x64/develop-ca6d30d7bf1811dda32c389bdb99aaeb975701c0/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on ca6d30d Oct 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the darwin x64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/13.3.2/darwin-x64/develop-ca6d30d7bf1811dda32c389bdb99aaeb975701c0/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on ca6d30d Oct 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the darwin arm64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/13.3.2/darwin-arm64/develop-ca6d30d7bf1811dda32c389bdb99aaeb975701c0/cypress.tgz

Please sign in to comment.