1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 async
function loadURL(uri
, flags
) {
8 let chan
= NetUtil
.newChannel({
10 loadUsingSystemPrincipal
: true,
11 }).QueryInterface(Ci
.nsIHttpChannel
);
12 chan
.loadFlags
= Ci
.nsIChannel
.LOAD_INITIAL_DOCUMENT_URI
;
14 return new Promise(resolve
=> {
16 new ChannelListener((req
, buff
) => resolve({ req
, buff
}), null, flags
)
21 add_task(async
function test() {
22 let certdb
= Cc
["@mozilla.org/security/x509certdb;1"].getService(
25 addCertFromFile(certdb
, "http2-ca.pem", "CTu,u,u");
27 async
function check408retry(server
) {
28 info(`Testing ${server.constructor.name}`);
29 await server
.execute(`global.server_name = "${server.constructor.name}";`);
31 server
.constructor.name
== "NodeHTTPServer" ||
32 server
.constructor.name
== "NodeHTTPSServer"
34 await server
.registerPathHandler("/test", (req
, resp
) => {
35 let oldSock
= global
.socket
;
36 global
.socket
= resp
.socket
;
37 if (global
.socket
== oldSock
) {
38 // This function is handled within the httpserver where setTimeout is
40 // eslint-disable-next-line mozilla/no-arbitrary-setTimeout, no-undef
52 resp
.end(global
.server_name
);
55 await server
.registerPathHandler("/test", (req
, resp
) => {
56 global
.socket
= resp
.socket
;
57 if (!global
.sent408
) {
58 global
.sent408
= true;
64 resp
.end(global
.server_name
);
68 async
function load() {
69 let { req
, buff
} = await
loadURL(
70 `${server.origin()}/test`,
73 equal(req
.status
, Cr
.NS_OK
);
74 equal(req
.QueryInterface(Ci
.nsIHttpChannel
).responseStatus
, 200);
75 equal(buff
, server
.constructor.name
);
77 req
.QueryInterface(Ci
.nsIHttpChannel
).protocolVersion
,
78 server
.constructor.name
== "NodeHTTP2Server" ? "h2" : "http/1.1"
88 await
with_node_servers(
89 [NodeHTTPServer
, NodeHTTPSServer
, NodeHTTP2Server
],