Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: force gzip when no accept encoding header is sent and use identity if gzip is not sent #28026

Merged
merged 14 commits into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions cli/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
<!-- See the ../guides/writing-the-cypress-changelog.md for details on writing the changelog. -->
## 13.3.2

_Released 10/25/2023 (PENDING)_

- 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 [#18025](https://github.com/cypress-io/cypress/issues/28025)
ryanthemanuel marked this conversation as resolved.
Show resolved Hide resolved
ryanthemanuel marked this conversation as resolved.
Show resolved Hide resolved

## 13.3.1

_Released 10/11/2023_
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
Loading
Loading