Skip to content

Commit bebf279

Browse files
annevkmoz-wptsync-bot
authored andcommitted
Bug 1689979 [wpt PR 27421] - HTTP/1 status code tests, a=testonly
Automatic update from web-platform-tests HTTP/1 status code tests For whatwg/fetch#1142 and whatwg/fetch#1159. -- wpt-commits: a0ff0251fc21d0acd2e2443a033b390f44399b43 wpt-pr: 27421
1 parent 93adc88 commit bebf279

File tree

2 files changed

+104
-0
lines changed

2 files changed

+104
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
def main(request, response):
2+
output = "HTTP/1.1 "
3+
output += request.GET.first("input")
4+
output += "\n" + "header-parsing: is sad" + "\n"
5+
response.writer.write(output)
6+
response.close_connection = True
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
[
2+
{
3+
input: "",
4+
expected: null
5+
},
6+
{
7+
input: "BLAH",
8+
expected: null
9+
},
10+
{
11+
input: "0 OK",
12+
expected: {
13+
status: 0,
14+
statusText: "OK"
15+
}
16+
},
17+
{
18+
input: "1 OK",
19+
expected: {
20+
status: 1,
21+
statusText: "OK"
22+
}
23+
},
24+
{
25+
input: "99 NOT OK",
26+
expected: {
27+
status: 99,
28+
statusText: "NOT OK"
29+
}
30+
},
31+
{
32+
input: "077 77",
33+
expected: {
34+
status: 77,
35+
statusText: "77"
36+
}
37+
},
38+
{
39+
input: "099 HELLO",
40+
expected: {
41+
status: 99,
42+
statusText: "HELLO"
43+
}
44+
},
45+
{
46+
input: "200",
47+
expected: {
48+
status: 200,
49+
statusText: ""
50+
}
51+
},
52+
{
53+
input: "999 DOES IT MATTER",
54+
expected: {
55+
status: 999,
56+
statusText: "DOES IT MATTER"
57+
}
58+
},
59+
{
60+
input: "1000 BOO",
61+
expected: null
62+
},
63+
{
64+
input: "0200 BOO",
65+
expected: null
66+
},
67+
{
68+
input: "65736 NOT 200 OR SOME SUCH",
69+
expected: null
70+
},
71+
{
72+
input: "131072 HI",
73+
expected: null
74+
},
75+
{
76+
input: "-200 TEST",
77+
expected: null
78+
},
79+
{
80+
input: "0xA",
81+
expected: null
82+
},
83+
{
84+
input: "C8",
85+
expected: null
86+
}
87+
].forEach(({ description, input, expected }) => {
88+
promise_test(async t => {
89+
if (expected !== null) {
90+
const response = await fetch("resources/status-code.py?input=" + input);
91+
assert_equals(response.status, expected.status);
92+
assert_equals(response.statusText, expected.statusText);
93+
assert_equals(response.headers.get("header-parsing"), "is sad");
94+
} else {
95+
await promise_rejects_js(t, TypeError, fetch("resources/status-code.py?input=" + input));
96+
}
97+
}, `HTTP/1.1 ${input} ${expected === null ? "(network error)" : ""}`);
98+
});

0 commit comments

Comments
 (0)