chrome.webRequest API header access changes

Showing 1-5 of 5 messages
chrome.webRequest API header access changes cdu...@chromium.org 28/11/18 11:29

Starting from Chrome 72, certain request and response headers will not be available by default in webRequest listeners which specify ‘requestHeaders’ or ‘responseHeaders’ in the extraInfoSpec. To view, modify, or delete these headers, the listener will need to also specify ‘extraHeaders’ in the extraInfoSpec. The affected headers are:


Request headers:

  • Accept-Language

  • Accept-Encoding

  • Cookie

  • Referer


Response headers:

  • Set-Cookie


Note: using ‘extraHeaders’ in a listener can impact performance for all matching requests, so only use this when absolutely necessary.


Thanks!

Re: chrome.webRequest API header access changes cdu...@chromium.org 28/11/18 13:16
One other note, before Chrome 72, an error will be thrown if 'extraHeaders' is added to extraInfoSpec. To make sure 'extraHeaders' is supported, you will want to check the corresponding options object for your listener, and only add 'extraHeaders' if it is available. For example, for onBeforeSendHeaders, you could do something like:

var extraInfoSpec = ['blocking', 'requestHeaders'];
if (chrome.webRequest.OnBeforeSendHeadersOptions.hasOwnProperty('EXTRA_HEADERS'))
  extraInfoSpec.push('extraHeaders');

And similar for other listeners.

Thanks!
Re: chrome.webRequest API header access changes Hlawuleka Maswanganyi 11/02/19 00:34
Is it possible to be more clear around what exactly one needs to do to resolve the "accept-language" issue?
Re: chrome.webRequest API header access changes Hlawuleka Maswanganyi 11/02/19 01:18
Never mind. Resolved.
unk...@googlegroups.com 15/02/19 03:40 <This message has been deleted.>