root/test_projects/modify_outgoing.html

Revision 3, 1.1 kB (checked in by atack2, 3 years ago)

Added modify_outgoing script; this is the first script that I have been able to make with this capability. Verified with LiveHttpHeaders?.

Line 
1 <html>
2 <script>
3 document.write("Waiting for you to make a request");
4
5         // Get us the privileges we need.
6         netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
7        
8         var myObserver = {
9                 observe: function(subject,topic,data){
10                         netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
11                         subject = subject.QueryInterface(Components.interfaces.nsIHttpChannel);
12                         subject.setRequestHeader("Overhaul", "yes", false);
13                         alert("Subject is now " + subject.getRequestHeader("Overhaul"));
14                 }
15         };
16        
17         // Create an observer
18         var observerService =
19                 Components.classes["@mozilla.org/observer-service;1"]
20     .getService(Components.interfaces.nsIObserverService);
21        
22         // Register us for the "http modify request"
23         // event, which happens when a request is made.
24         observerService.addObserver(myObserver,"http-on-modify-request",false);
25 </script>
26 <head>
27 <meta http-equiv="Content-Type" content="text/html;
28 charset=iso-8859-1">
29 <title>Test</title>
30 </head>
31
32 <body>
33 <input type="button" name="foo!" onclick="javascript: netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');" />
34 </body>
35 </html>
Note: See TracBrowser for help on using the browser.