fix(network): relax request matching heuristic (#3775)

Drop requirement for matching "origin" and "content-type" headers
in requests and request interceptions. This way javascript redirects
that use form submission start working.

Fix #3684.
This commit is contained in:
Andrey Lushnikov 2019-01-15 11:37:53 -08:00 committed by GitHub
parent e8bb26eb95
commit 04fbbd7cf0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 2 deletions

View File

@ -651,6 +651,8 @@ class Response {
} }
helper.tracePublicAPI(Response); helper.tracePublicAPI(Response);
const IGNORED_HEADERS = new Set(['accept', 'referer', 'x-devtools-emulate-network-conditions-client-id', 'cookie', 'origin', 'content-type']);
/** /**
* @param {!Protocol.Network.Request} request * @param {!Protocol.Network.Request} request
* @return {string} * @return {string}
@ -677,7 +679,7 @@ function generateRequestHash(request) {
for (let header of headers) { for (let header of headers) {
const headerValue = request.headers[header]; const headerValue = request.headers[header];
header = header.toLowerCase(); header = header.toLowerCase();
if (header === 'accept' || header === 'referer' || header === 'x-devtools-emulate-network-conditions-client-id' || header === 'cookie') if (IGNORED_HEADERS.has(header))
continue; continue;
hash.headers[header] = headerValue; hash.headers[header] = headerValue;
} }

View File

@ -266,7 +266,7 @@ module.exports.addTests = function({testRunner, expect}) {
expect(response.ok()).toBe(true); expect(response.ok()).toBe(true);
expect(response.remoteAddress().port).toBe(server.PORT); expect(response.remoteAddress().port).toBe(server.PORT);
}); });
xit('should work when POST is redirected with 302', async({page, server}) => { it('should work when POST is redirected with 302', async({page, server}) => {
server.setRedirect('/rredirect', '/empty.html'); server.setRedirect('/rredirect', '/empty.html');
await page.goto(server.EMPTY_PAGE); await page.goto(server.EMPTY_PAGE);
await page.setRequestInterception(true); await page.setRequestInterception(true);