简体   繁体   中英

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM