javascript-在Mozilla Addon Builder中重定向http请求URI
作者:互联网
我在Mozilla的Addon Builder中定义了一个http-on-modify-request观察者,并希望重定向请求(更改subject.URI.spec),但是Firefox抱怨:
Error: An exception occurred.
Traceback (most recent call last):
File "http://chrome.angrybirds.com/", line 2536, in null
File "http://chrome.angrybirds.com/", line 2344, in null
File "http://chrome.angrybirds.com/", line 2988, in wi
File "http://chrome.angrybirds.com/", line 1756, in ti
File "http://chrome.angrybirds.com/", line 1231, in Ji
File "http://chrome.angrybirds.com/", line 3366, in Ri
File "http://chrome.angrybirds.com/", line 2381, in Di
File "http://chrome.angrybirds.com/", line 2956, in Ni
File "http://chrome.angrybirds.com/", line 3366, in DHb
File "http://chrome.angrybirds.com/", line 3340, in oHb
File "http://chrome.angrybirds.com/", line 1869, in Eic
File "http://chrome.angrybirds.com/", line 3285, in BS
File "http://chrome.angrybirds.com/", line 3362, in _Jb
File "http://chrome.angrybirds.com/", line 3054, in _Bb
File "http://chrome.angrybirds.com/", line 2020, in dJb
File "http://chrome.angrybirds.com/", line 2889, in fJb
File "resource://jid0-[snipped id]-api-utils-lib/observer-service.js", line 176, in null
this.callback(subject, data);
File "resource://jid0-[snipped id]-moddedbirds-url-rewriter-lib/main.js", line 11, in null
if(endsWith(s.URI.spec,search)) s.URI.spec=replace;
[Exception... "Component returned failure code: 0x80004004 (NS_ERROR_ABORT)
[nsIURI.spec]" nsresult: "0x80004004 (NS_ERROR_ABORT)" location: "JS frame
:: resource://jid0-[snipped id]-api-utils-lib/securable-module.js
-> resource://jid0-[snipped id]-moddedbirds-url-rewriter-lib/main.js ::
<TOP_LEVEL> :: line 11" data: no]
为什么不起作用?
也许我不能使用http-on-modify-request观察器重写URI?
我怎么做?
解决方法:
是的,nsIChannel docs说“与该通道相对应的URI.它的值是不可变的.只读.”不可变的检查似乎确实返回了NS_ERROR_ABORT(source).
不幸的是,这个人(Redirecting Request (nsiHttpChannel?) in Firefox Extensions)没有发布他找到的解决方案,也在mozillazine上问了here和here这个问题.
我最好的主意是为此做了大量工作:尝试nsITraceableChannel.Wladimirhere的主意是“对nsIChannel.notificationCallbacks进行所有必要的调用,然后取消该请求”. Bug 286159对此进行了一些讨论(2005年似乎没有一种方法可以完全做到这一点).
由于这是一个反复出现的问题,如果您收到Necko peer的确认,然后在MDC上进行了记录,那就太好了.
标签:mozilla,firefox,firefox-addon,firefox-addon-sdk,javascript 来源: https://codeday.me/bug/20191202/2084992.html