Skip to content

Commit

Permalink
fix: request extra headers on Chrome
Browse files Browse the repository at this point in the history
Starting from Chrome 72, `extraHeaders` must be specified
to get and set cookies during requests.
  • Loading branch information
dessant committed Dec 19, 2019
1 parent 88477cf commit d46abe4
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/background/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -400,13 +400,18 @@ async function searchEngine(imgData, search, options, tabIndex, tabActive) {
120000
); // 2 minutes

const extraInfo = ['blocking', 'responseHeaders'];
if (targetEnv !== 'firefox') {
extraInfo.push('extraHeaders');
}

browser.webRequest.onHeadersReceived.addListener(
taobaoResponseCallback,
{
urls: ['https://www.taobao.com/*'],
tabId
},
['blocking', 'responseHeaders']
extraInfo
);

return {requestHeaders: details.requestHeaders};
Expand All @@ -424,12 +429,17 @@ async function searchEngine(imgData, search, options, tabIndex, tabActive) {
60000
); // 1 minute

const extraInfo = ['blocking', 'requestHeaders'];
if (targetEnv !== 'firefox') {
extraInfo.push('extraHeaders');
}

browser.webRequest.onBeforeSendHeaders.addListener(
taobaoRequestCallback,
{
urls: ['https://www.taobao.com/']
},
['blocking', 'requestHeaders']
extraInfo
);
}
}
Expand Down

0 comments on commit d46abe4

Please sign in to comment.