0

is there any chrome API or DOM API to get the whole HTTP header that browser received from the service(as the following snippet)


HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length

<?xml version="1.0" encoding="utf-8"?>
<objPlaceOrderResponse xmlns="https://api.efxnow.com/webservices2.3">
 ......

and i wana to modify this HTTP header(eg:i would modify the content-type first and then brower handle this http), how can i do it?

thanks very much!

Sudarshan
  • 18,140
  • 7
  • 53
  • 61
wbhuang
  • 11

1 Answers1

0

You can add an event Listener through weRequest API to modify response headers or request headers.

Sample Implementation

chrome.webRequest.onHeadersReceived.addListener(

function (details) {
    for (var i = 0; i < details.responseHeaders.length; ++i) {
        if (details.responseHeaders[i].name === 'X-Frame-Options') {
            details.responseHeaders.splice(i, 1);
            break;
        }
    }
    return {
        responseHeaders: details.responseHeaders
    };
}, {
    urls: ["<all_urls>"]
}, ["blocking", "responseHeaders"]);

References

Sudarshan
  • 18,140
  • 7
  • 53
  • 61