mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-09 21:33:43 +00:00
3199602600
--HG-- extra : rebase_source : 66ce23e335720742724250d248c9947dfd4eb33c
44 lines
1.2 KiB
JavaScript
44 lines
1.2 KiB
JavaScript
do_load_httpd_js();
|
|
|
|
var httpserver = new nsHttpServer();
|
|
var index = 0;
|
|
|
|
function setupChannel(url)
|
|
{
|
|
var ios = Components.classes["@mozilla.org/network/io-service;1"].
|
|
getService(Ci.nsIIOService);
|
|
var chan = ios.newChannel("http://localhost:4444" + url, "", null);
|
|
var httpChan = chan.QueryInterface(Components.interfaces.nsIHttpChannel);
|
|
return httpChan;
|
|
}
|
|
|
|
function completeTest1(request, data, ctx)
|
|
{
|
|
httpserver.stop(do_test_finished);
|
|
}
|
|
|
|
function run_test()
|
|
{
|
|
httpserver.registerPathHandler("/2xcl", handler);
|
|
httpserver.start(4444);
|
|
|
|
var channel = setupChannel("/2xcl");
|
|
channel.asyncOpen(new ChannelListener(completeTest1,
|
|
channel, CL_EXPECT_FAILURE), null);
|
|
do_test_pending();
|
|
}
|
|
|
|
function handler(metadata, response)
|
|
{
|
|
var body = "012345678901234567890123456789";
|
|
response.seizePower();
|
|
response.write("HTTP/1.0 200 OK\r\n");
|
|
response.write("Content-Type: text/plain\r\n");
|
|
response.write("Content-Length: 20\r\n");
|
|
response.write("Content-Length: 30\r\n");
|
|
response.write("\r\n");
|
|
response.write(body);
|
|
response.finish();
|
|
}
|
|
|