Reputation: 48085
I'm dealing with some mp3 link on the internet.
When using Chrome developer tool, I see some have response header with Content-Type:application/octet-stream
(links like these force Chrome to download), some links have reponse header with Content-Type:audio/mpeg
(links like these allow Chrome to play them streamingly).
Are there any Chrome extensions that allow changing response header? Because I want to change Content-Type
Upvotes: 9
Views: 14512
Reputation: 4162
See the Chrome developer page.
Here's a simple example that modifies Content-Type
of https://www.google.com/
to text/plain.
chrome.webRequest.onHeadersReceived.addListener(details => {
let header = details.responseHeaders.find(e => e.name.toLowerCase() === 'content-type') ;
header.value = 'text/plain';
return {responseHeaders: details.responseHeaders};
}, {urls: ['https://www.google.com/']}, ['blocking', 'responseHeaders']);
Note that you have to declare both webRequest
and webRequestBlocking
permissions in manifest.json
.
Upvotes: 19