|
1 Cu.import("resource://testing-common/httpd.js"); |
|
2 |
|
3 var httpserv; |
|
4 |
|
5 function TestListener() { |
|
6 } |
|
7 |
|
8 TestListener.prototype.onStartRequest = function(request, context) { |
|
9 } |
|
10 |
|
11 TestListener.prototype.onStopRequest = function(request, context, status) { |
|
12 httpserv.stop(do_test_finished); |
|
13 } |
|
14 |
|
15 function run_test() { |
|
16 httpserv = new HttpServer(); |
|
17 |
|
18 httpserv.registerPathHandler("/bug412945", bug412945); |
|
19 |
|
20 httpserv.start(-1); |
|
21 |
|
22 // make request |
|
23 var channel = |
|
24 Components.classes["@mozilla.org/network/io-service;1"]. |
|
25 getService(Components.interfaces.nsIIOService). |
|
26 newChannel("http://localhost:" + httpserv.identity.primaryPort + |
|
27 "/bug412945", null, null); |
|
28 |
|
29 channel.QueryInterface(Components.interfaces.nsIHttpChannel); |
|
30 channel.requestMethod = "POST"; |
|
31 channel.asyncOpen(new TestListener(), null); |
|
32 |
|
33 do_test_pending(); |
|
34 } |
|
35 |
|
36 function bug412945(metadata, response) { |
|
37 if (!metadata.hasHeader("Content-Length") || |
|
38 metadata.getHeader("Content-Length") != "0") |
|
39 { |
|
40 do_throw("Content-Length header not found!"); |
|
41 } |
|
42 } |