Skip to content

Commit decefa6

Browse files
authored
Remove invalid status line tests and replace them with valid status line tests (dart-lang#1018)
1 parent e19094a commit decefa6

File tree

2 files changed

+20
-13
lines changed

2 files changed

+20
-13
lines changed

pkgs/http_client_conformance_tests/lib/src/response_status_line_server.dart

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ void hybridMain(StreamChannel<Object?> channel) async {
2929
socket.writeAll(
3030
[
3131
statusLine,
32+
'Access-Control-Allow-Origin: *',
3233
'Content-Length: 0',
3334
'\r\n', // Add \r\n at the end of this header section.
3435
],

pkgs/http_client_conformance_tests/lib/src/response_status_line_tests.dart

+19-13
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ import 'package:test/test.dart';
1010
import 'response_status_line_server_vm.dart'
1111
if (dart.library.html) 'response_status_line_server_web.dart';
1212

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.
1417
void testResponseStatusLine(Client client) async {
1518
group('response status line', () {
1619
late String host;
@@ -23,17 +26,20 @@ void testResponseStatusLine(Client client) async {
2326
host = 'localhost:${await httpServerQueue.next}';
2427
});
2528

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+
});
3844
});
3945
}

0 commit comments

Comments
 (0)