@@ -28,7 +28,7 @@ public static IEnumerable<TestCase> GetTestCases()
2828 PayloadFactory = ctx => MakeRequest ( $ "GET / HTTP/1.1\n Host: { ctx . HostHeader } \r \n \r \n ") ,
2929 Expected = new ExpectedBehavior
3030 {
31- ExpectedStatus = StatusCodeRange . Range4xx ,
31+ ExpectedStatus = StatusCodeRange . Exact ( 400 ) ,
3232 AllowConnectionClose = true
3333 }
3434 } ;
@@ -42,7 +42,7 @@ public static IEnumerable<TestCase> GetTestCases()
4242 PayloadFactory = ctx => MakeRequest ( $ "GET / HTTP/1.1\r \n Host: { ctx . HostHeader } \n X-Test: value\r \n \r \n ") ,
4343 Expected = new ExpectedBehavior
4444 {
45- ExpectedStatus = StatusCodeRange . Range4xx ,
45+ ExpectedStatus = StatusCodeRange . Exact ( 400 ) ,
4646 AllowConnectionClose = true
4747 }
4848 } ;
@@ -56,8 +56,7 @@ public static IEnumerable<TestCase> GetTestCases()
5656 PayloadFactory = ctx => MakeRequest ( $ "GET / HTTP/1.1\r \n Host: { ctx . HostHeader } \r \n X-Test: value\r \n continued\r \n \r \n ") ,
5757 Expected = new ExpectedBehavior
5858 {
59- ExpectedStatus = StatusCodeRange . Range4xx ,
60- AllowConnectionClose = true
59+ ExpectedStatus = StatusCodeRange . Exact ( 400 )
6160 }
6261 } ;
6362
@@ -66,12 +65,11 @@ public static IEnumerable<TestCase> GetTestCases()
6665 Id = "RFC9110-5.6.2-SP-BEFORE-COLON" ,
6766 Description = "Whitespace between header name and colon must be rejected" ,
6867 Category = TestCategory . Compliance ,
69- RfcReference = "RFC 9110 §5.6.2 " ,
68+ RfcReference = "RFC 9112 §5" ,
7069 PayloadFactory = ctx => MakeRequest ( $ "GET / HTTP/1.1\r \n Host: { ctx . HostHeader } \r \n X-Test : value\r \n \r \n ") ,
7170 Expected = new ExpectedBehavior
7271 {
73- ExpectedStatus = StatusCodeRange . Range4xx ,
74- AllowConnectionClose = true
72+ ExpectedStatus = StatusCodeRange . Exact ( 400 )
7573 }
7674 } ;
7775
@@ -84,7 +82,7 @@ public static IEnumerable<TestCase> GetTestCases()
8482 PayloadFactory = ctx => MakeRequest ( $ "GET / HTTP/1.1\r \n Host: { ctx . HostHeader } \r \n \r \n ") ,
8583 Expected = new ExpectedBehavior
8684 {
87- ExpectedStatus = StatusCodeRange . Range4xx ,
85+ ExpectedStatus = StatusCodeRange . Exact ( 400 ) ,
8886 AllowConnectionClose = true
8987 }
9088 } ;
@@ -94,12 +92,11 @@ public static IEnumerable<TestCase> GetTestCases()
9492 Id = "RFC9112-7.1-MISSING-HOST" ,
9593 Description = "Request without Host header must be rejected with 400" ,
9694 Category = TestCategory . Compliance ,
97- RfcReference = "RFC 9112 §7.1 " ,
95+ RfcReference = "RFC 9112 §3.2 " ,
9896 PayloadFactory = _ => MakeRequest ( "GET / HTTP/1.1\r \n \r \n " ) ,
9997 Expected = new ExpectedBehavior
10098 {
101- ExpectedStatus = StatusCodeRange . Range4xx ,
102- AllowConnectionClose = true
99+ ExpectedStatus = StatusCodeRange . Exact ( 400 )
103100 }
104101 } ;
105102
@@ -112,8 +109,14 @@ public static IEnumerable<TestCase> GetTestCases()
112109 PayloadFactory = ctx => MakeRequest ( $ "GET / HTTP/9.9\r \n Host: { ctx . HostHeader } \r \n \r \n ") ,
113110 Expected = new ExpectedBehavior
114111 {
115- ExpectedStatus = StatusCodeRange . Range4xxOr5xx ,
116- AllowConnectionClose = true
112+ CustomValidator = ( response , state ) =>
113+ {
114+ if ( response is null )
115+ return state == ConnectionState . ClosedByServer ? TestVerdict . Pass : TestVerdict . Fail ;
116+ if ( response . StatusCode is 400 or 505 )
117+ return TestVerdict . Pass ;
118+ return TestVerdict . Fail ;
119+ }
117120 }
118121 } ;
119122
@@ -126,7 +129,7 @@ public static IEnumerable<TestCase> GetTestCases()
126129 PayloadFactory = ctx => MakeRequest ( $ "GET / HTTP/1.1\r \n Host: { ctx . HostHeader } \r \n : empty-name\r \n \r \n ") ,
127130 Expected = new ExpectedBehavior
128131 {
129- ExpectedStatus = StatusCodeRange . Range4xx ,
132+ ExpectedStatus = StatusCodeRange . Exact ( 400 ) ,
130133 AllowConnectionClose = true
131134 }
132135 } ;
@@ -140,8 +143,7 @@ public static IEnumerable<TestCase> GetTestCases()
140143 PayloadFactory = ctx => MakeRequest ( $ "GET / HTTP/1.1\r Host: { ctx . HostHeader } \r \n \r \n ") ,
141144 Expected = new ExpectedBehavior
142145 {
143- ExpectedStatus = StatusCodeRange . Range4xx ,
144- AllowConnectionClose = true
146+ ExpectedStatus = StatusCodeRange . Exact ( 400 )
145147 }
146148 } ;
147149
@@ -154,7 +156,7 @@ public static IEnumerable<TestCase> GetTestCases()
154156 PayloadFactory = ctx => MakeRequest ( $ "GET HTTP/1.1\r \n Host: { ctx . HostHeader } \r \n \r \n ") ,
155157 Expected = new ExpectedBehavior
156158 {
157- ExpectedStatus = StatusCodeRange . Range4xx ,
159+ ExpectedStatus = StatusCodeRange . Exact ( 400 ) ,
158160 AllowConnectionClose = true
159161 }
160162 } ;
@@ -168,7 +170,7 @@ public static IEnumerable<TestCase> GetTestCases()
168170 PayloadFactory = ctx => MakeRequest ( $ "GET /path#frag HTTP/1.1\r \n Host: { ctx . HostHeader } \r \n \r \n ") ,
169171 Expected = new ExpectedBehavior
170172 {
171- ExpectedStatus = StatusCodeRange . Range4xx ,
173+ ExpectedStatus = StatusCodeRange . Exact ( 400 ) ,
172174 AllowConnectionClose = true
173175 }
174176 } ;
@@ -186,7 +188,7 @@ public static IEnumerable<TestCase> GetTestCases()
186188 {
187189 if ( state is ConnectionState . TimedOut or ConnectionState . ClosedByServer )
188190 return TestVerdict . Pass ;
189- if ( response is not null && response . StatusCode > = 400 )
191+ if ( response is not null && response . StatusCode = = 400 )
190192 return TestVerdict . Pass ;
191193 return TestVerdict . Fail ;
192194 }
@@ -202,7 +204,7 @@ public static IEnumerable<TestCase> GetTestCases()
202204 PayloadFactory = ctx => MakeRequest ( $ "GET / HTTP/1.1\r \n Host: { ctx . HostHeader } \r \n Bad[Name: value\r \n \r \n ") ,
203205 Expected = new ExpectedBehavior
204206 {
205- ExpectedStatus = StatusCodeRange . Range4xx ,
207+ ExpectedStatus = StatusCodeRange . Exact ( 400 ) ,
206208 AllowConnectionClose = true
207209 }
208210 } ;
@@ -216,7 +218,7 @@ public static IEnumerable<TestCase> GetTestCases()
216218 PayloadFactory = ctx => MakeRequest ( $ "GET / HTTP/1.1\r \n Host: { ctx . HostHeader } \r \n NoColonHere\r \n \r \n ") ,
217219 Expected = new ExpectedBehavior
218220 {
219- ExpectedStatus = StatusCodeRange . Range4xx ,
221+ ExpectedStatus = StatusCodeRange . Exact ( 400 ) ,
220222 AllowConnectionClose = true
221223 }
222224 } ;
@@ -226,12 +228,11 @@ public static IEnumerable<TestCase> GetTestCases()
226228 Id = "RFC9110-5.4-DUPLICATE-HOST" ,
227229 Description = "Duplicate Host headers with different values must be rejected" ,
228230 Category = TestCategory . Compliance ,
229- RfcReference = "RFC 9110 §5.4 " ,
231+ RfcReference = "RFC 9112 §3.2 " ,
230232 PayloadFactory = ctx => MakeRequest ( $ "GET / HTTP/1.1\r \n Host: { ctx . HostHeader } \r \n Host: other.example.com\r \n \r \n ") ,
231233 Expected = new ExpectedBehavior
232234 {
233- ExpectedStatus = StatusCodeRange . Range4xx ,
234- AllowConnectionClose = true
235+ ExpectedStatus = StatusCodeRange . Exact ( 400 )
235236 }
236237 } ;
237238
@@ -244,7 +245,7 @@ public static IEnumerable<TestCase> GetTestCases()
244245 PayloadFactory = ctx => MakeRequest ( $ "POST / HTTP/1.1\r \n Host: { ctx . HostHeader } \r \n Content-Length: abc\r \n \r \n ") ,
245246 Expected = new ExpectedBehavior
246247 {
247- ExpectedStatus = StatusCodeRange . Range4xx ,
248+ ExpectedStatus = StatusCodeRange . Exact ( 400 ) ,
248249 AllowConnectionClose = true
249250 }
250251 } ;
@@ -258,7 +259,7 @@ public static IEnumerable<TestCase> GetTestCases()
258259 PayloadFactory = ctx => MakeRequest ( $ "POST / HTTP/1.1\r \n Host: { ctx . HostHeader } \r \n Content-Length: +5\r \n \r \n hello") ,
259260 Expected = new ExpectedBehavior
260261 {
261- ExpectedStatus = StatusCodeRange . Range4xx ,
262+ ExpectedStatus = StatusCodeRange . Exact ( 400 ) ,
262263 AllowConnectionClose = true
263264 }
264265 } ;
0 commit comments