File: http-request-hook.js

package info (click to toggle)
conkeror 1.0.3%2Bgit170123-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 1,988 kB
  • sloc: ansic: 280; sh: 255; xml: 173; makefile: 69
file content (32 lines) | stat: -rw-r--r-- 849 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/**
 * (C) Copyright 2013 John J. Foerch
 *
 * Use, modification, and distribution are subject to the terms specified in the
 * COPYING file.
**/

define_hook("http_request_hook");

var http_request_observer = {
    observe: function (subject, topic, data) {
        if (topic != "http-on-modify-request")
            return;
        subject.QueryInterface(Ci.nsIHttpChannel);
        http_request_hook.run(subject);
    }
};

function http_request_hook_enable () {
    observer_service.addObserver(http_request_observer,
                                 "http-on-modify-request",
                                 false);
}

function http_request_hook_disable () {
    observer_service.removeObserver(http_request_observer,
                                    "http-on-modify-request");
}

http_request_hook_enable();

provide("http-request-hook");