From c91f6f956fb035ee1e6f82dc722fdd5e8aeae1cb Mon Sep 17 00:00:00 2001 From: Ryan Manuel Date: Tue, 10 Oct 2023 16:52:22 -0500 Subject: [PATCH 01/11] fix: only allow identity encoding when accept encoding is not present in requests --- packages/proxy/lib/http/request-middleware.ts | 4 +++- .../test/integration/http_requests_spec.js | 21 ++++++++++++++++--- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/packages/proxy/lib/http/request-middleware.ts b/packages/proxy/lib/http/request-middleware.ts index 23b9798639a7..d6c199fabf0c 100644 --- a/packages/proxy/lib/http/request-middleware.ts +++ b/packages/proxy/lib/http/request-middleware.ts @@ -365,8 +365,10 @@ 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 { + this.req.headers['accept-encoding'] = 'identity' } span?.end() diff --git a/packages/server/test/integration/http_requests_spec.js b/packages/server/test/integration/http_requests_spec.js index 5777514dd11e..20c9f0451be8 100644 --- a/packages/server/test/integration/http_requests_spec.js +++ b/packages/server/test/integration/http_requests_spec.js @@ -1139,10 +1139,9 @@ describe('Routes', () => { }) it('removes accept-encoding when nothing is supported', function () { - nock(this.server.remoteStates.current().origin, { - badheaders: ['accept-encoding'], - }) + nock(this.server.remoteStates.current().origin) .get('/accept') + .matchHeader('accept-encoding', 'identity') .reply(200, 'accept') return this.rp({ @@ -1158,6 +1157,22 @@ describe('Routes', () => { expect(res.body).to.eq('accept') }) }) + + it('removes accept-encoding when no header is passed', function () { + nock(this.server.remoteStates.current().origin) + .get('/accept') + .matchHeader('accept-encoding', 'identity') + .reply(200, 'accept') + + return this.rp({ + url: 'http://www.github.com/accept', + }) + .then((res) => { + expect(res.statusCode).to.eq(200) + + expect(res.body).to.eq('accept') + }) + }) }) context('304 Not Modified', () => { From 7e7a5204db74323b514ee17d2e855673d4d4655b Mon Sep 17 00:00:00 2001 From: Ryan Manuel Date: Tue, 10 Oct 2023 16:57:12 -0500 Subject: [PATCH 02/11] Update request-middleware.ts --- packages/proxy/lib/http/request-middleware.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/proxy/lib/http/request-middleware.ts b/packages/proxy/lib/http/request-middleware.ts index d6c199fabf0c..f37d81e4dd40 100644 --- a/packages/proxy/lib/http/request-middleware.ts +++ b/packages/proxy/lib/http/request-middleware.ts @@ -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({ From f306c5a78d05952b8ce81d4e22009ead13af6946 Mon Sep 17 00:00:00 2001 From: Ryan Manuel Date: Wed, 11 Oct 2023 10:06:17 -0500 Subject: [PATCH 03/11] Update packages/server/test/integration/http_requests_spec.js Co-authored-by: Chris Breiding --- packages/server/test/integration/http_requests_spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/server/test/integration/http_requests_spec.js b/packages/server/test/integration/http_requests_spec.js index 20c9f0451be8..be1c9012ed92 100644 --- a/packages/server/test/integration/http_requests_spec.js +++ b/packages/server/test/integration/http_requests_spec.js @@ -1158,7 +1158,7 @@ describe('Routes', () => { }) }) - it('removes accept-encoding when no header is passed', function () { + it('sets accept-encoding header to "identity" when no header is passed', function () { nock(this.server.remoteStates.current().origin) .get('/accept') .matchHeader('accept-encoding', 'identity') From ddb6e8973b9d08be577cd58d222c106eb715395e Mon Sep 17 00:00:00 2001 From: Ryan Manuel Date: Wed, 11 Oct 2023 10:06:28 -0500 Subject: [PATCH 04/11] Update packages/server/test/integration/http_requests_spec.js Co-authored-by: Chris Breiding --- packages/server/test/integration/http_requests_spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/server/test/integration/http_requests_spec.js b/packages/server/test/integration/http_requests_spec.js index be1c9012ed92..1387c3cac9e0 100644 --- a/packages/server/test/integration/http_requests_spec.js +++ b/packages/server/test/integration/http_requests_spec.js @@ -1138,7 +1138,7 @@ describe('Routes', () => { }) }) - it('removes accept-encoding when nothing is supported', function () { + it('sets accept-encoding header to "identity" when nothing is supported', function () { nock(this.server.remoteStates.current().origin) .get('/accept') .matchHeader('accept-encoding', 'identity') From 84b1af8ec4f38a9dee3b9de027147f8e247173b4 Mon Sep 17 00:00:00 2001 From: Ryan Manuel Date: Wed, 11 Oct 2023 11:41:38 -0500 Subject: [PATCH 05/11] Update packages/proxy/lib/http/request-middleware.ts --- packages/proxy/lib/http/request-middleware.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/proxy/lib/http/request-middleware.ts b/packages/proxy/lib/http/request-middleware.ts index f37d81e4dd40..50fdc50f5aa7 100644 --- a/packages/proxy/lib/http/request-middleware.ts +++ b/packages/proxy/lib/http/request-middleware.ts @@ -368,7 +368,8 @@ const StripUnsupportedAcceptEncoding: RequestMiddleware = function () { this.req.headers['accept-encoding'] = 'identity' } } else { - this.req.headers['accept-encoding'] = 'identity' + // 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` + this.req.headers['accept-encoding'] = 'gzip' } span?.end() From f8da6bb6ed03518b79455f923816dacf8ea39de1 Mon Sep 17 00:00:00 2001 From: Ryan Manuel Date: Wed, 11 Oct 2023 11:42:17 -0500 Subject: [PATCH 06/11] Apply suggestions from code review --- packages/server/test/integration/http_requests_spec.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/server/test/integration/http_requests_spec.js b/packages/server/test/integration/http_requests_spec.js index 1387c3cac9e0..2d49e3d2f88b 100644 --- a/packages/server/test/integration/http_requests_spec.js +++ b/packages/server/test/integration/http_requests_spec.js @@ -1158,10 +1158,10 @@ describe('Routes', () => { }) }) - it('sets accept-encoding header to "identity" when no header is passed', function () { + it('sets accept-encoding header to "gzip" when no header is passed', function () { nock(this.server.remoteStates.current().origin) .get('/accept') - .matchHeader('accept-encoding', 'identity') + .matchHeader('accept-encoding', 'gzip') .reply(200, 'accept') return this.rp({ From 1f3e25b754970011daff41226a92fab14b77f47c Mon Sep 17 00:00:00 2001 From: Ryan Manuel Date: Sat, 14 Oct 2023 15:52:29 -0500 Subject: [PATCH 07/11] Update CHANGELOG.md --- cli/CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cli/CHANGELOG.md b/cli/CHANGELOG.md index a8aaa68ab025..1595e2a6a0b2 100644 --- a/cli/CHANGELOG.md +++ b/cli/CHANGELOG.md @@ -1,4 +1,10 @@ +## 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) + ## 13.3.1 _Released 10/11/2023_ From f00778c59230d71bbe5ca20a77811aab161e86c6 Mon Sep 17 00:00:00 2001 From: Ryan Manuel Date: Sat, 14 Oct 2023 21:37:37 -0500 Subject: [PATCH 08/11] fix tests --- packages/proxy/lib/http/request-middleware.ts | 5 +- .../test/integration/http_requests_spec.js | 141 ++++++++++++++++-- 2 files changed, 129 insertions(+), 17 deletions(-) diff --git a/packages/proxy/lib/http/request-middleware.ts b/packages/proxy/lib/http/request-middleware.ts index 50fdc50f5aa7..d8ccd58b2fc4 100644 --- a/packages/proxy/lib/http/request-middleware.ts +++ b/packages/proxy/lib/http/request-middleware.ts @@ -368,8 +368,9 @@ const StripUnsupportedAcceptEncoding: RequestMiddleware = function () { 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` - this.req.headers['accept-encoding'] = 'gzip' + // 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() diff --git a/packages/server/test/integration/http_requests_spec.js b/packages/server/test/integration/http_requests_spec.js index 2d49e3d2f88b..921ed2097edc 100644 --- a/packages/server/test/integration/http_requests_spec.js +++ b/packages/server/test/integration/http_requests_spec.js @@ -257,6 +257,7 @@ describe('Routes', () => { url: 'http://www.github.com/', headers: { 'Cookie': '__cypress.initial=true', + 'Accept-Encoding': 'identity', }, }) .then((res) => { @@ -294,6 +295,7 @@ describe('Routes', () => { url: 'https://localhost:8443/', headers: { 'Accept': 'text/html, application/xhtml+xml, */*', + 'Accept-Encoding': 'identity', }, }) .then((res) => { @@ -970,6 +972,7 @@ describe('Routes', () => { url: 'http://www.github.com/', headers: { 'Cookie': '__cypress.initial=true', + 'Accept-Encoding': 'identity', }, }) .then((res) => { @@ -1158,10 +1161,10 @@ describe('Routes', () => { }) }) - it('sets accept-encoding header to "gzip" when no header is passed', function () { + it('sets accept-encoding header to "gzip,identity" when no header is passed', function () { nock(this.server.remoteStates.current().origin) .get('/accept') - .matchHeader('accept-encoding', 'gzip') + .matchHeader('accept-encoding', 'gzip,identity') .reply(200, 'accept') return this.rp({ @@ -1365,6 +1368,7 @@ describe('Routes', () => { url: 'http://www.github.com/index.html', headers: { 'Cookie': '__cypress.initial=true', + 'Accept-Encoding': 'identity', }, }) .then((res) => { @@ -1447,7 +1451,12 @@ describe('Routes', () => { }, }) .then(() => { - return this.rp(`${this.proxy}/foo/views/test/index.html`) + return this.rp({ + url: `${this.proxy}/foo/views/test/index.html`, + headers: { + 'Accept-Encoding': 'identity', + }, + }) .then((res) => { expect(res.statusCode).to.eq(404) expect(res.body).to.include('Cypress errored trying to serve this file from your system:') @@ -1474,7 +1483,12 @@ describe('Routes', () => { 'Content-Type': 'text/html', }) - return this.rp('http://www.github.com/index.html') + return this.rp({ + url: 'http://www.github.com/index.html', + headers: { + 'Accept-Encoding': 'identity', + }, + }) .then((res) => { expect(res.statusCode).to.eq(500) @@ -1583,6 +1597,7 @@ describe('Routes', () => { url: 'http://localhost:8080/login', headers: { 'Cookie': '__cypress.initial=true', + 'Accept-Encoding': 'identity', }, }) .then((res) => { @@ -1606,6 +1621,7 @@ describe('Routes', () => { url: 'http://localhost:8080/login', headers: { 'Cookie': '__cypress.initial=true', + 'Accept-Encoding': 'identity', }, }) .then((res) => { @@ -1745,6 +1761,7 @@ describe('Routes', () => { headers: { 'Cookie': '__cypress.initial=true', 'x-custom': 'value', + 'Accept-Encoding': 'identity', }, }) .then((res) => { @@ -1906,6 +1923,7 @@ describe('Routes', () => { 'Cookie': '__cypress.initial=false', 'Origin': 'http://localhost:8080', 'Accept': 'text/html, application/xhtml+xml, */*', + 'Accept-Encoding': 'identity', }, }) .then((res) => { @@ -1923,7 +1941,12 @@ describe('Routes', () => { .then(() => { this.server.onRequest(fn) - return this.rp(url) + return this.rp({ + url, + headers: { + 'Accept-Encoding': 'identity', + }, + }) }).then((res) => { expect(res.statusCode).to.eq(200) @@ -2551,6 +2574,7 @@ describe('Routes', () => { url: 'http://www.cypress.io/bar', headers: { 'Cookie': '__cypress.initial=true', + 'Accept-Encoding': 'identity', }, }) const body = cleanResponseBody(res.body) @@ -2573,6 +2597,7 @@ describe('Routes', () => { url: 'http://www.cypress.io/bar', headers: { 'Cookie': '__cypress.initial=true', + 'Accept-Encoding': 'identity', }, }) const body = cleanResponseBody(res.body) @@ -2592,6 +2617,7 @@ describe('Routes', () => { url: 'http://www.cypress.io/bar', headers: { 'Cookie': '__cypress.initial=true', + 'Accept-Encoding': 'identity', }, }) .then((res) => { @@ -2612,6 +2638,7 @@ describe('Routes', () => { url: 'http://www.cypress.io/bar', headers: { 'Cookie': '__cypress.initial=true', + 'Accept-Encoding': 'identity', }, }) .then((res) => { @@ -2634,6 +2661,7 @@ describe('Routes', () => { url: 'http://www.cypress.io/bar', headers: { 'Cookie': '__cypress.initial=true', + 'Accept-Encoding': 'identity', }, }) .then((res) => { @@ -2654,6 +2682,7 @@ describe('Routes', () => { url: 'http://www.cypress.io/bar', headers: { 'Cookie': '__cypress.initial=true', + 'Accept-Encoding': 'identity', }, }) .then((res) => { @@ -2676,6 +2705,7 @@ describe('Routes', () => { url: 'http://www.cypress.io/bar', headers: { 'Cookie': '__cypress.initial=true', + 'Accept-Encoding': 'identity', }, }) .then((res) => { @@ -2698,6 +2728,7 @@ describe('Routes', () => { url: 'http://www.cypress.io/bar', headers: { 'Cookie': '__cypress.initial=true', + 'Accept-Encoding': 'identity', }, }) .then((res) => { @@ -2719,6 +2750,7 @@ describe('Routes', () => { headers: { 'Cookie': '__cypress.initial=false', 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', + 'Accept-Encoding': 'identity', }, }) .then((res) => { @@ -2746,6 +2778,7 @@ describe('Routes', () => { url: 'http://www.cypress.io/bar', headers: { 'Cookie': '__cypress.initial=true', + 'Accept-Encoding': 'identity', }, }) .then((res) => { @@ -2753,7 +2786,12 @@ describe('Routes', () => { expect(res.headers['location']).to.eq('http://www.cypress.io/foo') expect(res.headers['set-cookie']).to.match(/initial=true/) - return this.rp(res.headers['location']) + return this.rp({ + url: res.headers['location'], + headers: { + 'Accept-Encoding': 'identity', + }, + }) .then((res) => { expect(res.statusCode).to.eq(200) expect(res.headers['set-cookie']).to.match(/initial=;/) @@ -2777,6 +2815,7 @@ describe('Routes', () => { headers: { 'Cookie': '__cypress.initial=true', 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', + 'Accept-Encoding': 'identity', }, }) .then((res) => { @@ -2797,6 +2836,7 @@ describe('Routes', () => { url: `${this.proxy}/elements.html`, headers: { 'Cookie': '__cypress.initial=true', + 'Accept-Encoding': 'identity', }, }) .then((res) => { @@ -2818,6 +2858,7 @@ describe('Routes', () => { url: 'http://www.cypress.io/bar', headers: { 'Cookie': '__cypress.initial=false', + 'Accept-Encoding': 'identity', }, }) .then((res) => { @@ -2836,6 +2877,7 @@ describe('Routes', () => { url: 'https://localhost:8443/', headers: { 'Cookie': '__cypress.initial=true', + 'Accept-Encoding': 'identity', }, }) const body = cleanResponseBody(res.body) @@ -2859,6 +2901,7 @@ describe('Routes', () => { url: 'https://www.google.com/', headers: { 'Cookie': '__cypress.initial=true', + 'Accept-Encoding': 'identity', }, }) .then((res) => { @@ -2884,6 +2927,7 @@ describe('Routes', () => { url: 'https://www.cypress.io/', headers: { 'Accept': 'text/html, application/xhtml+xml, */*', + 'Accept-Encoding': 'identity', }, }) .then((res) => { @@ -2904,6 +2948,7 @@ describe('Routes', () => { url: 'https://www.foobar.com:8443/index.html', headers: { 'Cookie': '__cypress.initial=true', + 'Accept-Encoding': 'identity', }, }) const body = cleanResponseBody(res.body) @@ -2922,6 +2967,7 @@ describe('Routes', () => { url: 'https://docs.foobar.com:8443/index.html', headers: { 'Cookie': '__cypress.initial=true', + 'Accept-Encoding': 'identity', }, }) const body = cleanResponseBody(res.body) @@ -2940,6 +2986,7 @@ describe('Routes', () => { headers: { 'Cookie': '__cypress.initial=false', 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', + 'Accept-Encoding': 'identity', }, }) .then((res) => { @@ -2964,6 +3011,7 @@ describe('Routes', () => { headers: { 'Cookie': '__cypress.initial=false', 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', + 'Accept-Encoding': 'identity', }, }) .then((res) => { @@ -2987,6 +3035,7 @@ describe('Routes', () => { headers: { 'Cookie': '__cypress.initial=false', 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', + 'Accept-Encoding': 'identity', }, }) .then((res) => { @@ -3011,6 +3060,7 @@ describe('Routes', () => { 'Cookie': '__cypress.initial=false', 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'X-Cypress-Is-AUT-Frame': 'true', + 'Accept-Encoding': 'identity', }, }) .then((res) => { @@ -3034,6 +3084,7 @@ describe('Routes', () => { json: true, headers: { 'Cookie': '__cypress.initial=false', + 'Accept-Encoding': 'identity', }, }) .then((res) => { @@ -3055,6 +3106,7 @@ describe('Routes', () => { headers: { 'Cookie': '__cypress.initial=false', 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', + 'Accept-Encoding': 'identity', }, }) .then((res) => { @@ -3074,6 +3126,7 @@ describe('Routes', () => { headers: { 'Cookie': '__cypress.initial=true', 'Accept': 'application/json', + 'Accept-Encoding': 'identity', }, }) .then((res) => { @@ -3097,6 +3150,7 @@ describe('Routes', () => { headers: { 'Cookie': '__cypress.initial=false', 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', + 'Accept-Encoding': 'identity', 'X-Requested-With': 'XMLHttpRequest', }, }) @@ -3119,6 +3173,7 @@ describe('Routes', () => { const headers = { 'Cookie': '__cypress.initial=false', + 'Accept-Encoding': 'identity', } headers['Accept'] = type @@ -3155,6 +3210,7 @@ describe('Routes', () => { headers: { 'Cookie': '__cypress.initial=false', 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', + 'Accept-Encoding': 'identity', }, }) .then((res) => { @@ -3180,12 +3236,14 @@ describe('Routes', () => { .get('/index.html') .reply(200, html, { 'Content-Type': 'text/html', + 'Accept-Encoding': 'identity', }) return this.rp({ url: 'http://www.google.com/index.html', headers: { 'Cookie': '__cypress.initial=true', + 'Accept-Encoding': 'identity', }, }) .then((res) => { @@ -3204,7 +3262,12 @@ describe('Routes', () => { 'Content-Type': 'application/javascript', }) - return this.rp('http://www.google.com/app.js') + return this.rp({ + url: 'http://www.google.com/app.js', + headers: { + 'Accept-Encoding': 'identity', + }, + }) .then((res) => { expect(res.statusCode).to.eq(200) @@ -3415,6 +3478,7 @@ describe('Routes', () => { url: 'http://www.google.com/index.html', headers: { 'Cookie': '__cypress.initial=true', + 'Accept-Encoding': 'identity', }, }) .then((res) => { @@ -3433,7 +3497,12 @@ describe('Routes', () => { 'Content-Type': 'application/javascript', }) - return this.rp('http://www.google.com/app.js') + return this.rp({ + url: 'http://www.google.com/app.js', + headers: { + 'Accept-Encoding': 'identity', + }, + }) .then((res) => { expect(res.statusCode).to.eq(200) @@ -3462,6 +3531,7 @@ describe('Routes', () => { headers: { 'Cookie': '__cypress.initial=true', 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', + 'Accept-Encoding': 'identity', }, }) .then((res) => { @@ -3487,6 +3557,7 @@ describe('Routes', () => { headers: { 'Cookie': '__cypress.initial=false', 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', + 'Accept-Encoding': 'identity', }, }) .then((res) => { @@ -3519,6 +3590,7 @@ describe('Routes', () => { headers: { 'Cookie': '__cypress.initial=true', 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', + 'Accept-Encoding': 'identity', }, }) .then((res) => { @@ -3536,7 +3608,12 @@ describe('Routes', () => { }) it('sets etag', function () { - return this.rp(`${this.proxy}/assets/app.css`) + return this.rp({ + url: `${this.proxy}/assets/app.css`, + headers: { + 'Accept-Encoding': 'identity', + }, + }) .then((res) => { expect(res.statusCode).to.eq(200) expect(res.body).to.eq('html { color: black; }') @@ -3553,7 +3630,12 @@ describe('Routes', () => { }) it('streams from file system', function () { - return this.rp(`${this.proxy}/assets/app.css`) + return this.rp({ + url: `${this.proxy}/assets/app.css`, + headers: { + 'Accept-Encoding': 'identity', + }, + }) .then((res) => { expect(res.statusCode).to.eq(200) @@ -3571,7 +3653,12 @@ describe('Routes', () => { }) it('disregards anything past the pathname', function () { - return this.rp(`${this.proxy}/assets/app.css?foo=bar#hash`) + return this.rp({ + url: `${this.proxy}/assets/app.css?foo=bar#hash`, + headers: { + 'Accept-Encoding': 'identity', + }, + }) .then((res) => { expect(res.statusCode).to.eq(200) @@ -3580,7 +3667,12 @@ describe('Routes', () => { }) it('can serve files with spaces in the path', function () { - return this.rp(`${this.proxy}/a space/foo.txt`) + return this.rp({ + url: `${this.proxy}/a space/foo.txt`, + headers: { + 'Accept-Encoding': 'identity', + }, + }) .then((res) => { expect(res.statusCode).to.eq(200) @@ -3610,6 +3702,7 @@ describe('Routes', () => { headers: { 'Cookie': '__cypress.initial=false', 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', + 'Accept-Encoding': 'identity', }, }) .then((res) => { @@ -3625,6 +3718,7 @@ describe('Routes', () => { headers: { 'Cookie': '__cypress.initial=false', 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', + 'Accept-Encoding': 'identity', }, }) .then((res) => { @@ -3655,6 +3749,7 @@ describe('Routes', () => { json: true, headers: { 'Cookie': '__cypress.initial=false', + 'Accept-Encoding': 'identity', }, }) .then((res) => { @@ -3670,6 +3765,7 @@ describe('Routes', () => { headers: { 'Cookie': '__cypress.initial=true', 'Accept': 'application/json', + 'Accept-Encoding': 'identity', }, }) .then((res) => { @@ -3706,7 +3802,12 @@ describe('Routes', () => { 'Content-Type': 'text/css', }) - return this.rp('http://getbootstrap.com/assets/css/application.css') + return this.rp({ + url: 'http://getbootstrap.com/assets/css/application.css', + headers: { + 'Accept-Encoding': 'identity', + }, + }) .then((res) => { expect(res.statusCode).to.eq(200) @@ -3727,7 +3828,12 @@ describe('Routes', () => { 'Content-Type': 'text/html', }) - return this.rp('http://getbootstrap.com/css') + return this.rp({ + url: 'http://getbootstrap.com/css', + headers: { + 'Accept-Encoding': 'identity', + }, + }) .then((res) => { expect(res.statusCode).to.eq(200) }) @@ -3741,7 +3847,12 @@ describe('Routes', () => { 'Content-Type': 'text/css', }) - return this.rp('http://getbootstrap.com/assets/css/application.css') + return this.rp({ + url: 'http://getbootstrap.com/assets/css/application.css', + headers: { + 'Accept-Encoding': 'identity', + }, + }) .then((res) => { expect(res.statusCode).to.eq(200) From e29a2b2af9ea7448db5d45ff54e1d2499a241370 Mon Sep 17 00:00:00 2001 From: Ryan Manuel Date: Sat, 14 Oct 2023 22:25:36 -0500 Subject: [PATCH 09/11] fix tests --- packages/server/test/integration/server_spec.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/server/test/integration/server_spec.js b/packages/server/test/integration/server_spec.js index 8ffa7095448b..a6b5dbeb836f 100644 --- a/packages/server/test/integration/server_spec.js +++ b/packages/server/test/integration/server_spec.js @@ -292,7 +292,12 @@ describe('Server', () => { cookies: [], }) }).then(() => { - return this.rp('http://localhost:2000/does-not-exist') + return this.rp({ + url: 'http://localhost:2000/does-not-exist', + headers: { + 'Accept-Encoding': 'identity', + }, + }) .then((res) => { expect(res.statusCode).to.eq(404) expect(res.body).to.include('Cypress errored trying to serve this file from your system:') From 8ab226d4adbae7851dfbac3d9be118a50322ca6b Mon Sep 17 00:00:00 2001 From: Ryan Manuel Date: Sun, 15 Oct 2023 15:11:35 -0500 Subject: [PATCH 10/11] Update cli/CHANGELOG.md --- cli/CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cli/CHANGELOG.md b/cli/CHANGELOG.md index 1595e2a6a0b2..8cd458a2db08 100644 --- a/cli/CHANGELOG.md +++ b/cli/CHANGELOG.md @@ -3,6 +3,8 @@ _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 [#18025](https://github.com/cypress-io/cypress/issues/28025) ## 13.3.1 From 03caf54fe54fd3ae245a04fa0a3190fa68375e65 Mon Sep 17 00:00:00 2001 From: Ryan Manuel Date: Sun, 15 Oct 2023 15:39:17 -0500 Subject: [PATCH 11/11] Update cli/CHANGELOG.md --- cli/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/CHANGELOG.md b/cli/CHANGELOG.md index 8cd458a2db08..63f4ec958791 100644 --- a/cli/CHANGELOG.md +++ b/cli/CHANGELOG.md @@ -5,7 +5,7 @@ _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 [#18025](https://github.com/cypress-io/cypress/issues/28025) +- 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). ## 13.3.1