Firefox アドオンに問題があります。
私の拡張機能を使用して、特定のパターンに一致するリクエストをリダイレクトしたいと考えています。これまでのところ、リダイレクトは正常に機能しています
httpChannel.redirectTo()
ここで、リダイレクトのリクエスト ヘッダーを追加/変更したいと思います(ここで説明されているように: https://developer.mozilla.org/en-US/docs/Setting_HTTP_request_headers )
これまでの私のコード:
console.log("start");
const {Cu,Ci} = require('chrome');
Cu.import('resource://gre/modules/Services.jsm');
var httpRequestObserver =
{
observe: function(subject, topic, data)
{
var httpChannel, requestURL;
if (topic == "http-on-modify-request") {
httpChannel = subject.QueryInterface(Ci.nsIHttpChannel);
requestURL = httpChannel.URI.spec;
if (requestURL.indexOf('www.3und80.de') > -1) {
console.log("match url");
newURL = 'http://www.genialschenken.de/';
/*This has no effect*/
httpChannel.setRequestHeader("X-Hello", "World", false);
console.log("redirecting...");
httpChannel.redirectTo(Services.io.newURI(newURL, null, null));
}
return;
}
}
};
Services.obs.addObserver(httpRequestObserver, "http-on-modify-request", false);
残念ながら、ライン
httpChannel.setRequestHeader("X-Hello", "World", false);
効果はありません。私は何を間違っていますか?
前もって感謝します!