0

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);

効果はありません。私は何を間違っていますか?

前もって感謝します!

4

1 に答える 1

0

IRC より:

00:58 落ちたノイダ: nsIChannelEventSink

00:58 Fallen と nsIInterfaceRequestor

00:59 Fallen リンク読んでないけど

01:00 落ちたノイダ: http://mxr.mozilla.org/comm-central/source/calendar/providers/caldav/calDavCalendar.js#2828

@ 3und80これをさらに調査して、ここで解決策を開発しましょう。

于 2014-11-28T11:51:12.163 に答える