Skip to content

Instantly share code, notes, and snippets.

@DenVdmj
Last active June 30, 2018 02:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DenVdmj/bd6f03481b7a22742d26b27bd6b1b642 to your computer and use it in GitHub Desktop.
Save DenVdmj/bd6f03481b7a22742d26b27bd6b1b642 to your computer and use it in GitHub Desktop.
Enable brotli supporting for http requests. Chrome extension.
chrome.webRequest.onBeforeSendHeaders.addListener(details => {
let headers = details.requestHeaders;
let header = headers.find(header => /accept-encoding/i.test(header.name));
if (header) {
header.value = header.value.split(/\s*,\s*/).concat('br').join(', ');
}
return { requestHeaders: headers }
}, {
urls: ['*://*/*']
}, [
'blocking', 'requestHeaders'
]);
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
{
"manifest_version": 2,
"version": "0.0.1.1",
"name": "Brotli for http requests",
"description": "Brotli is not only for https requests, but also http requests. This extension just add “br” to “accept-encoding” request header. First and foremost for debugging and site local (WAMP) testing.",
"icons": {
"32": "brotli-logo-32x32.png",
"48": "brotli-logo-48x48.png",
"128": "brotli-logo-128x128.png",
"256": "brotli-logo-256x256.png"
},
"browser_action": {
"default_icon": {
"32": "brotli-logo-32x32.png",
"48": "brotli-logo-48x48.png",
"128": "brotli-logo-128x128.png",
"256": "brotli-logo-256x256.png"
}
},
"background": {
"scripts": ["background.js"]
},
"permissions": [
"tabs",
"contextMenus",
"webRequest",
"webRequestBlocking",
"file:///*/*",
"*://*/*"
],
"web_accessible_resources": [
"*://*/*"
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment