extract whole http request via chrome.webRequest.onBeforeSendHeaders API

Viewed 54

My goal is to extract the whole http request from the chrome.downloads.onDeterminingFilename event. Since this event doesn't give this information, such as headers, type of the request (POST,GET,..). I am using another event chrome.webRequest.onBeforeSendHeaders. The second event gives all needed information, but it occurs more often.

how can I "combine" those events? All I need is all headrs,request type etc of the download file event

I tried to declare a global variable like:

var request_detailes;
chrome.webRequest.onBeforeSendHeaders.addListener(
    function (details) {
        request_detailes= details;
        return {
            requestHeaders: details.requestHeaders
        };
    }, {
        urls: ["<all_urls>"]
    },
    ["blocking", "requestHeaders", "extraHeaders"]);

chrome.downloads.onDeterminingFilename.addListener(foo);

function foo()
{
// here I'm using request_detailes...
}

my solution works but not always since the chrome.webRequest.onBeforeSendHeaders occur very often

chrome.downloads

0 Answers
Related