@@ -10,7 +10,10 @@ import 'package:test/test.dart';
10
10
import 'response_status_line_server_vm.dart'
11
11
if (dart.library.html) 'response_status_line_server_web.dart' ;
12
12
13
- /// Tests that the [Client] correctly processes the response status line.
13
+ /// Tests that the [Client] correctly processes the response status line (e.g.
14
+ /// 'HTTP/1.1 200 OK\r\n').
15
+ ///
16
+ /// Clients behavior varies considerably if the status line is not valid.
14
17
void testResponseStatusLine (Client client) async {
15
18
group ('response status line' , () {
16
19
late String host;
@@ -23,17 +26,20 @@ void testResponseStatusLine(Client client) async {
23
26
host = 'localhost:${await httpServerQueue .next }' ;
24
27
});
25
28
26
- test (
27
- 'without status code' ,
28
- () async {
29
- httpServerChannel.sink.add ('HTTP/1.1 OK' );
30
- await expectLater (
31
- client.get (Uri .http (host, '' )),
32
- throwsA (isA <ClientException >()),
33
- );
34
- },
35
- skip:
36
- 'Enable after https://github.com/dart-lang/http/issues/1013 is fixed' ,
37
- );
29
+ test ('complete' , () async {
30
+ httpServerChannel.sink.add ('HTTP/1.1 201 Created' );
31
+ final response = await client.get (Uri .http (host, '' ));
32
+ expect (response.statusCode, 201 );
33
+ expect (response.reasonPhrase, 'Created' );
34
+ });
35
+
36
+ test ('no reason phrase' , () async {
37
+ httpServerChannel.sink.add ('HTTP/1.1 201' );
38
+ final response = await client.get (Uri .http (host, '' ));
39
+ expect (response.statusCode, 201 );
40
+ // An empty Reason-Phrase is allowed according to RFC-2616. Any of these
41
+ // interpretations seem reasonable.
42
+ expect (response.reasonPhrase, anyOf (isNull, '' , 'Created' ));
43
+ });
38
44
});
39
45
}
0 commit comments