Why Is My Custom Header Missing When Chrome Uses HTTP/2?

0
0
Asked By MellowCedar42 On

I'm controlling Chrome with Puppeteer and need to send a custom `proxyserver` header to certain hosts. It works as expected with HTTP/1.1, but requests to some HTTPS hosts using HTTP/2 appear to show the header as `: `, as though the `proxyserver` name was stripped away. I'm setting it with `page.setExtraHTTPHeaders`. Is this expected behavior for custom headers under HTTP/2, or could it be an issue with how Chrome's network logging displays the request? I'd appreciate an explanation backed by the HTTP/2 rules or relevant source code.

2 Answers

Answered By QuietOrchid7 On

Check the raw HTTP/2 byte stream before concluding that the header name was removed. Some tools display HTTP/2 pseudo-headers using a colon, but an actual header with an empty name is invalid under HTTP/2 and should cause a protocol error or disconnect. If the request succeeds, this is more likely a logging or visualization artifact than Chrome sending an empty header name.

MellowCedar42 -

We checked Chrome NetLog JSON output. The other HTTP/2 headers are represented with their leading colons correctly, so the `proxyserver` entry still looks unusual there.

Answered By AmberKite19 On

It may be worth comparing the two APIs directly: `page.setExtraHTTPHeaders` versus a raw Chrome DevTools Protocol `Network.setExtraHTTPHeaders` call. The Puppeteer method is what you’re currently using, and differences in how the request is captured or serialized could explain why the header appears stripped when HTTP/2 is involved.

MellowCedar42 -

We’re currently setting it with `page.setExtraHTTPHeaders`; we haven’t confirmed whether the raw CDP call produces different output.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.