netwerk/test/unit/test_bug412945.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/netwerk/test/unit/test_bug412945.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,42 @@
     1.4 +Cu.import("resource://testing-common/httpd.js");
     1.5 +
     1.6 +var httpserv;
     1.7 +
     1.8 +function TestListener() {
     1.9 +}
    1.10 +
    1.11 +TestListener.prototype.onStartRequest = function(request, context) {
    1.12 +}
    1.13 +
    1.14 +TestListener.prototype.onStopRequest = function(request, context, status) {
    1.15 +  httpserv.stop(do_test_finished);
    1.16 +}
    1.17 +
    1.18 +function run_test() {
    1.19 +  httpserv = new HttpServer();
    1.20 +
    1.21 +  httpserv.registerPathHandler("/bug412945", bug412945);
    1.22 +
    1.23 +  httpserv.start(-1);
    1.24 +
    1.25 +  // make request
    1.26 +  var channel =
    1.27 +      Components.classes["@mozilla.org/network/io-service;1"].
    1.28 +      getService(Components.interfaces.nsIIOService).
    1.29 +      newChannel("http://localhost:" + httpserv.identity.primaryPort +
    1.30 +                 "/bug412945", null, null);
    1.31 +
    1.32 +  channel.QueryInterface(Components.interfaces.nsIHttpChannel);
    1.33 +  channel.requestMethod = "POST";
    1.34 +  channel.asyncOpen(new TestListener(), null);
    1.35 +
    1.36 +  do_test_pending();
    1.37 +}
    1.38 +
    1.39 +function bug412945(metadata, response) {
    1.40 +  if (!metadata.hasHeader("Content-Length") ||
    1.41 +      metadata.getHeader("Content-Length") != "0")
    1.42 +  {
    1.43 +    do_throw("Content-Length header not found!");
    1.44 +  }
    1.45 +}

mercurial