3 function check_request_header(chan
, name
, value
) {
6 chanValue
= chan
.getRequestHeader(name
);
8 do_throw("Expected to find header '" + name
+ "' but didn't find it");
10 Assert
.equal(chanValue
, value
);
14 var chan
= NetUtil
.newChannel({
15 uri
: "http://www.mozilla.org/",
16 loadUsingSystemPrincipal
: true,
17 }).QueryInterface(Ci
.nsIHttpChannel
);
19 check_request_header(chan
, "host", "www.mozilla.org");
20 check_request_header(chan
, "Host", "www.mozilla.org");
22 chan
.setRequestHeader("foopy", "bar", false);
23 check_request_header(chan
, "foopy", "bar");
25 chan
.setRequestHeader("foopy", "baz", true);
26 check_request_header(chan
, "foopy", "bar, baz");
28 for (let i
= 0; i
< 100; ++i
) {
29 chan
.setRequestHeader("foopy" + i
, i
, false);
32 for (let i
= 0; i
< 100; ++i
) {
33 check_request_header(chan
, "foopy" + i
, i
);
38 chan
.setRequestHeader("foo:py", "baz", false);
43 do_throw("header with colon not rejected");
48 chan
.setRequestHeader("foopy", "b\naz", false);
53 do_throw("header value with newline not rejected");
58 chan
.setRequestHeader("foopy\u0080", "baz", false);
63 do_throw("header name with non-ASCII not rejected");
68 chan
.setRequestHeader("foopy", "b\u0000az", false);
73 do_throw("header value with null-byte not rejected");