fix: fix loading redirects with TE: chunked (#8896)

This commit is contained in:
Zach Bloomquist
2020-10-22 13:17:58 -04:00
committed by GitHub
parent e82c28613e
commit e6fe0cdc07
3 changed files with 20 additions and 1 deletions

View File

@@ -411,6 +411,17 @@ describe('network stubbing', function () {
})
context('network handling', function () {
// @see https://github.com/cypress-io/cypress/issues/8497
it('can load transfer-encoding: chunked redirects', function () {
const url4 = 'http://localhost:3501/fixtures/generic.html'
const url3 = `http://localhost:3501/redirect?href=${encodeURIComponent(url4)}`
const url2 = `https://localhost:3502/redirect?chunked=1&href=${encodeURIComponent(url3)}`
const url1 = `https://localhost:3502/redirect?chunked=1&href=${encodeURIComponent(url2)}`
cy.visit(url1)
.location('href').should('eq', url4)
})
context('can intercept against any domain', function () {
beforeEach(function () {
// reset origin

View File

@@ -42,7 +42,14 @@ const createApp = (port) => {
})
app.get('/redirect', (req, res) => {
res.redirect(301, req.query.href)
if (req.query.chunked) {
res.setHeader('transfer-encoding', 'chunked')
res.removeHeader('content-length')
}
res.statusCode = 301
res.setHeader('Location', req.query.href)
res.end()
})
// allows us to serve the testrunner into an iframe for testing

View File

@@ -299,6 +299,7 @@ const OmitProblematicHeaders: ResponseMiddleware = function () {
'set-cookie',
'x-frame-options',
'content-length',
'transfer-encoding',
'content-security-policy',
'content-security-policy-report-only',
'connection',