Skip to content

Instantly share code, notes, and snippets.

@DenVdmj
Last active Jun 30, 2018
Embed
What would you like to do?
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'
]);
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