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
You can set response headers, you can add response headers. And you can wonder what the difference is. But think about it for a second, then do this exercise. Draw a line from the HttpResponse method to the method's behavior.
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
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With