Salman Patel
Salman Patel

Reputation: 77

Chrome extension chrome.webRequest API - Some http request headers not coming in request headers

I was working on chrome extension with motive of intercepting all HTTP(S) requests/responses and log all headers into persistent file (on disk). I was almost close to my goal. But when I looked some requests closely, I found that in many requests "If-None-Match" and "If-Modified-Since" are missing in requestHeaders. Though, I can see them in Network panel displayed by the Developer Tools.

I tried hard to figure out any patterns, causing such behavior. But, unfortunately there is no such pattern.

Anybody please help.

Upvotes: 1

Views: 1363

Answers (1)

Dmitri Pavlutin
Dmitri Pavlutin

Reputation: 19130

The receive the list of requestHeader is necessary to use the onBeforeSendHeaders event from chrome.webRequest API.

In the onBeforeSendHeaders description is mentioned that some headers are not available for reading/processing:

  • Authorization
  • Cache-Control
  • Connection
  • Content-Length
  • Host
  • If-Modified-Since
  • If-None-Match
  • If-Range
  • Partial-Data
  • Pragma
  • Proxy-Authorization
  • Proxy-Connection
  • Transfer-Encoding

I'm afraid you will not be able to read or modify these headers, because it's an API forced limitation.

Upvotes: 1

Related Questions