This repository has been archived by the owner on Aug 28, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathhttpd.patch
85 lines (74 loc) · 2.7 KB
/
httpd.patch
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
--- httpd.js.upstream 2011-01-08 03:15:04.000000000 +0300
+++ lib/httpd.js 2011-01-09 04:10:21.000000000 +0300
@@ -48,9 +48,7 @@
-Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
-const Cc = Components.classes;
-const Ci = Components.interfaces;
-const Cr = Components.results;
-const Cu = Components.utils;
-const CC = Components.Constructor;
+var {components,Cc,Ci,Cr,Cu} = require("chrome");
+components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
+
+const CC = components.Constructor;
@@ -59,3 +57,3 @@
/** True if debugging output is enabled, false otherwise. */
-var DEBUG = false; // non-const *only* so tweakable in server tests
+var DEBUG = true; // non-const *only* so tweakable in server tests
@@ -64,3 +62,3 @@
-var gGlobalObject = this;
+var gGlobalObject = Cc["@mozilla.org/systemprincipal;1"].createInstance();
@@ -226,3 +224,3 @@
* speedup over doing the same from base principles. See the docs at
- * http://developer.mozilla.org/en/docs/Components.Constructor for details.
+ * http://developer.mozilla.org/en/docs/components.Constructor for details.
*/
@@ -404,3 +402,3 @@
{
- classID: Components.ID("{54ef6f81-30af-4b1d-ac55-8ba811293e41}"),
+ classID: components.ID("{54ef6f81-30af-4b1d-ac55-8ba811293e41}"),
@@ -1959,3 +1957,3 @@
- var directory = metadata.getProperty("directory");
+ var directory = metadata.getProperty("directory").QueryInterface(Ci.nsILocalFile);
NS_ASSERT(directory && directory.isDirectory());
@@ -3909,3 +3907,3 @@
- if (!Components.isSuccessCode(statusCode))
+ if (!components.isSuccessCode(statusCode))
{
@@ -3978,3 +3976,3 @@
{
- if (!Components.isSuccessCode(statusCode))
+ if (!components.isSuccessCode(statusCode))
dumpn("*** WARNING: non-success statusCode in onStopRequest");
@@ -5120,4 +5118,8 @@
// XPCOM trappings
+if ("XPCOMUtils" in this && // Firefox 3.6 doesn't load XPCOMUtils in this scope for some reason...
+ "generateNSGetFactory" in XPCOMUtils) {
+ var NSGetFactory = XPCOMUtils.generateNSGetFactory([nsHttpServer]);
+}
+
-var NSGetFactory = XPCOMUtils.generateNSGetFactory([nsHttpServer]);
@@ -5179 +5181,23 @@
}
+
+function startServerAsync(port, basePath)
+{
+ if (basePath)
+ {
+ var lp = Cc["@mozilla.org/file/local;1"]
+ .createInstance(Ci.nsILocalFile);
+ lp.initWithPath(basePath);
+ }
+
+ var srv = new nsHttpServer();
+ if (lp)
+ srv.registerDirectory("/", lp);
+ srv.registerContentType("sjs", "sjs");
+ srv.identity.setPrimary("http", "localhost", port);
+ srv.start(port);
+ return srv;
+}
+
+exports.nsHttpServer = nsHttpServer;
+exports.server = server;
+exports.startServerAsync = startServerAsync;