New issue
Advanced search Search tips

Issue 795336 link

Starred by 3 users

Issue metadata

Status: Duplicate
Merged: issue 767683
Owner:
Closed: Jan 2018
Components:
EstimatedDays: ----
NextAction: ----
OS: Windows
Pri: 3
Type: Bug



Sign in to add a comment

Can't set Host: headers via Chrome DevTools "Network.setExtraHTTPHeaders" anymore

Reported by max.mais...@gmail.com, Dec 15 2017

Issue description

Chrome Version       : 63.0.3239.84
OS Version: 6.1 (Windows 7, Windows Server 2008 R2)

What steps will reproduce the problem?
1. Send the following JSON message to the DevTools API:
{"method":"Network.setExtraHTTPHeaders","id":33,"params":{"headers":{"Host":"www.example.com","Referer":"http://example.com/"}}}

2. Request the next page through the DevTools API:
{"id":35,"params":{"url":"http://127.0.0.1:61595/"},"method":"Page.navigate"}

3. Observe the headers on the receiving HTTP server

What is the expected result?

The Host: header has the value "www.example.com"
The Referer header has the value "http://example.com/"

What happens instead of that?
The Host: header has the value "127.0.0.1:61595"
The Referer header is empty

Please provide any additional information below. Attach a screenshot if
possible.

The following versions work/fail:

chrome-win32-62.0.3202.94    - work
chrome-win32-63.0.3239.108   - fail
chrome-win32-64.0.3282.0     - fail

This is a regression between Chrome v62 and Chrome 64. Chrome v63 used to work but since the .84 or .108 build, it also fails.

Please point out the relevant documentation in the Chrome DevTools. https://chromedevtools.github.io/devtools-protocol/tot/Network/

If you want an automated regression test, I have it at https://github.com/Corion/WWW-Mechanize-Chrome , but these tests require Perl.





 
Components: Platform>DevTools
Owner: caseq@chromium.org
Status: Assigned (was: Unconfirmed)

Comment 3 by beebw...@gmail.com, Dec 19 2017

I'm having the same problem on a Mac (happened after an update today: not sure what version I was running previously).

Network.setExtraHTTPHeaders fails on HeadlessChrome/63.0.3239.84 on Intel Mac OS X 10.13.2.
Just testing with a more recent build ( HeadlessChrome/65.0.3300.0 ) and part of it got fixed. The Host: header gets preserved, but the Referer: header is still missing:

2017/12/19 23:15:57 Sent message $VAR1 = '{"id":15,"method":"Network.setExtraHTT
PHeaders","params":{"headers":{"Host":"www.example.com","Referer":"http://exampl
e.com/","X-Another-Header":"Oh yes"}}}';
2017/12/19 23:15:57 Replying to 15 $VAR1 = {
          'result' => {},
          'id' => 15
        };
2017/12/19 23:15:57 Navigating to [http://127.0.0.1:57810/]
2017/12/19 23:15:57 Sent message $VAR1 = '{"params":{"url":"http://127.0.0.1:578
10/"},"id":16,"method":"Page.navigate"}';

... results in ...

2017/12/19 23:16:00 Dispatching message $VAR1 = {
          'params' => {
                        'request' => {
                                       'initialPriority' => 'VeryHigh',
                                       'method' => 'GET',
                                       'mixedContentType' => 'none',
                                       'headers' => {
                                                      'Referer' => 'http://examp
le.com/',
                                                      'X-Another-Header' => 'Oh
yes',
                                                      'User-Agent' => 'Mozilla/5
.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessC
hrome/65.0.3300.0 Safari/537.36',
                                                      'Upgrade-Insecure-Requests
' => '1',
                                                      'Host' => 'www.example.com
'
                                                    },
                                       'referrerPolicy' => 'unsafe-url',
                                       'url' => 'http://127.0.0.1:57810/'
                                     },
                        'documentURL' => 'http://127.0.0.1:57810/',
                        'requestId' => '8472.4',
                        'timestamp' => '2522288.401775',
                        'wallTime' => '1513721760.13734',
                        'frameId' => '(F4BDEF45EC61F87164347265A0A9F0D3)',
                        'type' => 'Document',
                        'loaderId' => '(C4D881F2FA0A0562FD3F5D896FF4F92F)',
                        'initiator' => {
                                         'type' => 'other'
                                       }
                      },
          'method' => 'Network.requestWillBeSent'
        };

... and then in this, where the Referer: header is not being sent at all:

2017/12/19 23:16:00 Dispatching message $VAR1 = {
          'params' => {
                        'frameId' => '(F4BDEF45EC61F87164347265A0A9F0D3)',
                        'timestamp' => '2522288.402331',
                        'response' => {
                                        'timing' => {
                                                      'workerStart' => -1,
                                                      'pushEnd' => 0,
                                                      'proxyStart' => '0.1260000
2810359',
                                                      'sslStart' => -1,
                                                      'proxyEnd' => '2250.228999
64824',
                                                      'sendStart' => '2250.58899
959549',
                                                      'pushStart' => 0,
                                                      'dnsStart' => '2250.270999
96805',
                                                      'receiveHeadersEnd' => '22
51.90499983728',
                                                      'workerReady' => -1,
                                                      'requestTime' => '2522286.
149213',
                                                      'sslEnd' => -1,
                                                      'sendEnd' => '2250.6209998
3916',
                                                      'connectEnd' => '2250.5299
9984473',
                                                      'dnsEnd' => '2250.27599977
329',
                                                      'connectStart' => '2250.27
599977329'
                                                    },
                                        'encodedDataLength' => 333,
                                        'status' => 200,
                                        'fromServiceWorker' => bless( do{\(my $o
 = 0)}, 'JSON::PP::Boolean' ),
                                        'headers' => {
                                                       'Content-Length' => '5441
',
                                                       'Set-Cookie' => 'log-serv
er-httponly=supersecret; path=/; HttpOnly
log-server=shazam2; path=/',
                                                       'Server' => 'libwww-perl-
daemon/6.01',
                                                       'Date' => 'Tue, 19 Dec 20
17 22:16:00 GMT',
                                                       'Connection' => 'close',
                                                       'Pragma' => 'no-cache',
                                                       'Cache-Control' => 'no-ca
che',
                                                       'Max-Age' => '0',
                                                       'Content-Type' => 'text/h
tml; charset=ISO-8859-1'
                                                     },
                                        'remotePort' => 57810,
                                        'connectionId' => 11,
                                        'protocol' => 'http/1.1',
                                        'url' => 'http://127.0.0.1:57810/',
                                        'requestHeadersText' => 'GET / HTTP/1.1
Host: www.example.com
Connection: keep-alive
Cache-Control: max-age=0
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML,
like Gecko) HeadlessChrome/65.0.3300.0 Safari/537.36
X-Another-Header: Oh yes
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/a
png,*/*;q=0.8
Accept-Encoding: gzip, deflate
Cookie: log-server-httponly=supersecret; log-server=shazam2
',
                                        'connectionReused' => $VAR1->{'params'}{
'response'}{'fromServiceWorker'},
                                        'mimeType' => 'text/html',
                                        'remoteIPAddress' => '127.0.0.1',
                                        'securityState' => 'neutral',
                                        'headersText' => 'HTTP/1.1 200 OK
Date: Tue, 19 Dec 2017 22:16:00 GMT
Server: libwww-perl-daemon/6.01
Cache-Control: no-cache
Connection: close
Pragma: no-cache
Content-Length: 5441
Content-Type: text/html; charset=ISO-8859-1
Max-Age: 0
Set-Cookie: log-server-httponly=supersecret; path=/; HttpOnly
Set-Cookie: log-server=shazam2; path=/

',
                                        'fromDiskCache' => $VAR1->{'params'}{'re
sponse'}{'fromServiceWorker'},
                                        'statusText' => 'OK',
                                        'requestHeaders' => {
                                                              'Accept-Encoding'
=> 'gzip, deflate',
                                                              'Upgrade-Insecure-
Requests' => '1',
                                                              'Cache-Control' =>
 'max-age=0',
                                                              'Connection' => 'k
eep-alive',
                                                              'User-Agent' => 'M
ozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) H
eadlessChrome/65.0.3300.0 Safari/537.36',
                                                              'Accept' => 'text/
html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8
',
                                                              'Host' => 'www.exa
mple.com',
                                                              'X-Another-Header'
 => 'Oh yes',
                                                              'Cookie' => 'log-s
erver-httponly=supersecret; log-server=shazam2'
                                                            }
                                      },
                        'type' => 'Document',
                        'requestId' => '8472.4',
                        'loaderId' => '(C4D881F2FA0A0562FD3F5D896FF4F92F)'
                      },
          'method' => 'Network.responseReceived'
        };

Comment 5 Deleted

I am also experiencing this issue. The initial request for Page.navigate does not have the headers applied.

The headers *are* being applied to resources that are loaded from the page I am navigating to (css, js, xhr, etc).

Environments:
Windows 10 -- Google Chrome 63.0.3239.108
Linux x64 -- Google Chrome 63.0.3239.108

It seems I misread my test output a bit. The Host: header works, but the Referer header is not added. This is also reflected in the log I pasted above.
Ah hah. The test output with Chrome 65 is correct, the Host: header gets sent correctly. But with HeadlessChrome/63.0.3239.108 , neither the Host: header nor the Referer: header get sent correctly.

Sorry for the confusion

Comment 9 by caseq@chromium.org, Jan 3 2018

Mergedinto: 767683
Status: Duplicate (was: Assigned)
Looks like duplicate of  issue 767683 . This was fixed in m64.
I can confirm that this is partially solved by Chrome 64 ("m64" ?), as the Host: header is sent correctly starting with Chrome 65. The Referer: header is still empty even though it was set explicitly.

I consider this a bug and don't see any documentation in the DevTools stating that Referer: headers can't be set. Should I open another issue for the Referer: header?

Sign in to add a comment