diff --git a/lib/NetworkManager.js b/lib/NetworkManager.js index ed85edffc85..66daac4a3fb 100644 --- a/lib/NetworkManager.js +++ b/lib/NetworkManager.js @@ -571,10 +571,12 @@ function generateRequestHash(request) { if (!normalizedURL.startsWith('data:')) { const headers = Object.keys(request.headers); headers.sort(); - for (const header of headers) { - if (header === 'Accept' || header === 'Referer' || header === 'X-DevTools-Emulate-Network-Conditions-Client-Id') + for (let header of headers) { + const headerValue = request.headers[header]; + header = header.toLowerCase(); + if (header === 'accept' || header === 'referer' || header === 'x-devtools-emulate-network-conditions-client-id') continue; - hash.headers[header] = request.headers[header]; + hash.headers[header] = headerValue; } } return JSON.stringify(hash); diff --git a/test/test.js b/test/test.js index 3bd62ff8ab8..c06accd8242 100644 --- a/test/test.js +++ b/test/test.js @@ -1332,6 +1332,16 @@ describe('Page', function() { const response = await page.goto(server.EMPTY_PAGE); expect(response.ok()).toBe(true); }); + it('should works with customizing referer headers', async({page, server}) => { + await page.setExtraHTTPHeaders({ 'referer': server.EMPTY_PAGE }); + await page.setRequestInterception(true); + page.on('request', request => { + expect(request.headers()['referer']).toBe(server.EMPTY_PAGE); + request.continue(); + }); + const response = await page.goto(server.EMPTY_PAGE); + expect(response.ok()).toBe(true); + }); it('should be abortable', async({page, server}) => { await page.setRequestInterception(true); page.on('request', request => {