1 function check_request_header(chan
, name
, value
) {
4 chanValue
= chan
.getRequestHeader(name
);
6 do_throw("Expected to find header '" + name
+ "' but didn't find it");
8 do_check_eq(chanValue
, value
);
12 var ios
= Components
.classes
["@mozilla.org/network/io-service;1"]
13 .getService(Components
.interfaces
.nsIIOService
);
14 var chan
= ios
.newChannel("http://www.mozilla.org/", null, null)
15 .QueryInterface(Components
.interfaces
.nsIHttpChannel
);
17 check_request_header(chan
, "host", "www.mozilla.org");
18 check_request_header(chan
, "Host", "www.mozilla.org");
20 chan
.setRequestHeader("foopy", "bar", false);
21 check_request_header(chan
, "foopy", "bar");
23 chan
.setRequestHeader("foopy", "baz", true);
24 check_request_header(chan
, "foopy", "bar, baz");
26 for (var i
= 0; i
< 100; ++i
)
27 chan
.setRequestHeader("foopy" + i
, i
, false);
29 for (var i
= 0; i
< 100; ++i
)
30 check_request_header(chan
, "foopy" + i
, i
);
34 chan
.setRequestHeader("foo:py", "baz", false);
39 do_throw("header with colon not rejected");
43 chan
.setRequestHeader("foopy", "b\naz", false);
48 do_throw("header value with newline not rejected");
52 chan
.setRequestHeader("foopy\u0080", "baz", false);
57 do_throw("header name with non-ASCII not rejected");
61 chan
.setRequestHeader("foopy", "b\u0000az", false);
66 do_throw("header value with null-byte not rejected");