Chrome WebRequest重定向到Blob网址

时间:2014-06-16 18:06:20

标签: javascript google-chrome google-chrome-extension google-chrome-devtools

我正在构建chrome扩展并使用chrome.webRequest来拦截所有GET请求。其中一个请求从http://test.com/bla.xml获取XML文件。我将此文件保存为chrome本地存储中的blob。

var blobUrl = URL.createObjectURL(blobData); // blobUrl created earlier in code

chrome.webRequest.onBeforeRequest.addListener(
    function (details) {
        if (details.url === 'http://test.com/bla.xml') {

            console.log($.get(blobUrl)) // this works 

            return { redirectUrl: blobUrl }; // this fails. 
        }

当我尝试使用更新的redirectUrl返回时,会出现问题。我可以在chrome>中看到检查>第一个jquery GET请求处理正常的网络,并通过blobUrl检索文件。但是,原始重定向请求将给我404未找到。如果我按照404中的链接,它是与jquery中使用的链接相同的链接,当我在浏览器中找到它时会找到它。

0 个答案:

没有答案
相关问题