45 new Test(
"http://localhost:4444/objHandler",
47 new Test(
"http://localhost:4444/functionHandler",
49 new Test(
"http://localhost:4444/non-existent-path",
59 var dirServ =
Cc[
"@mozilla.org/file/directory_service;1"]
60 .getService(
Ci.nsIProperties);
61 var
path = dirServ.get(
"CurProcD",
Ci.nsILocalFile);
62 srv.registerDirectory(
"/", path);
65 srv.registerPathHandler(
"/objHandler",
objHandler);
80 do_check_true(ch.contentLength > -1);
81 do_check_eq(ch.getResponseHeader(
"connection"),
"close");
82 do_check_false(ch.isNoStoreResponse());
90 do_check_true(ch.requestSucceeded);
91 do_check_eq(ch.getResponseHeader(
"content-type"),
"text/plain");
94 var reqMin = {}, reqMaj = {}, respMin = {}, respMaj = {};
95 ch.getRequestVersion(reqMaj, reqMin);
96 ch.getResponseVersion(respMaj, respMin);
97 do_check_true(reqMaj.value == respMaj.value &&
98 reqMin.value == respMin.value);
106 do_check_false(ch.requestSucceeded);
107 do_check_eq(ch.getResponseHeader(
"foopy"),
"quux-baz");
108 do_check_eq(ch.responseStatusText,
"Page Not Found");
110 var reqMin = {}, reqMaj = {}, respMin = {}, respMaj = {};
111 ch.getRequestVersion(reqMaj, reqMin);
112 ch.getResponseVersion(respMaj, respMin);
113 do_check_true(reqMaj.value == 1 && reqMin.value == 1);
114 do_check_true(respMaj.value == 1 && respMin.value == 1);
122 do_check_false(ch.requestSucceeded);
131 handle:
function(metadata, response)
133 response.setStatusLine(metadata.httpVersion, 200,
"OK");
134 response.setHeader(
"Content-Type",
"text/plain",
false);
136 var body =
"Request (slightly reformatted):\n\n";
137 body += metadata.method +
" " + metadata.path;
141 if (metadata.queryString)
142 body +=
"?" + metadata.queryString;
144 body +=
" HTTP/" + metadata.httpVersion +
"\n";
146 var headEnum = metadata.headers;
147 while (headEnum.hasMoreElements())
149 var fieldName = headEnum.getNext()
150 .QueryInterface(
Ci.nsISupportsString)
152 body += fieldName +
": " + metadata.getHeader(fieldName) +
"\n";
155 response.bodyOutputStream.write(body, body.length);
159 if (
id.equals(
Ci.nsISupports) ||
id.equals(
Ci.nsIHttpRequestHandler))
161 throw Cr.NS_ERROR_NOINTERFACE;
168 response.setStatusLine(
"1.1", 404,
"Page Not Found");
169 response.setHeader(
"foopy",
"quux-baz",
false);
175 var body =
"this is text\n";
176 response.bodyOutputStream.write(body, body.length);
do_check_eq(typeof PlacesUtils,"object")
function runHttpTests(testArray, done)
sbOSDControlService prototype QueryInterface
function start_objHandler(ch, cx)
function handle(request, response)
function functionHandler(metadata, response)
function start_non_existent_path(ch, cx)
function start_functionHandler(ch, cx)
function testComplete(srv)
function Test(path, initChannel, onStartRequest, onStopRequest)