Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[http_client_conformance_tests] add canRelyOnContentLength flag #1129

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ export 'src/server_errors_test.dart' show testServerErrors;
/// If [canReceiveSetCookieHeaders] is `false` then tests that require that
/// "set-cookie" headers be received by the client will not be run.
///
/// If [canRelyOnContentLength] is `false` then tests that require that
/// "content-length" header to be fully reliable will not be run.
/// Web browsers are handling content decoding and original body size is not
/// available. See https://fetch.spec.whatwg.org/#ref-for-handle-content-codings%E2%91%A0
///
/// The tests are run against a series of HTTP servers that are started by the
/// tests. If the tests are run in the browser, then the test servers are
/// started in another process. Otherwise, the test servers are run in-process.
Expand All @@ -76,6 +81,7 @@ void testAll(
bool preservesMethodCase = false,
bool canSendCookieHeaders = false,
bool canReceiveSetCookieHeaders = false,
bool canRelyOnContentLength = true,
}) {
testRequestBody(clientFactory());
testRequestBodyStreamed(clientFactory(),
Expand All @@ -86,7 +92,8 @@ void testAll(
canStreamResponseBody: canStreamResponseBody);
testRequestHeaders(clientFactory());
testRequestMethods(clientFactory(), preservesMethodCase: preservesMethodCase);
testResponseHeaders(clientFactory());
testResponseHeaders(clientFactory(),
canRelyOnContentLength: canRelyOnContentLength);
testResponseStatusLine(clientFactory());
testRedirect(clientFactory(), redirectAlwaysAllowed: redirectAlwaysAllowed);
testServerErrors(clientFactory());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import 'response_headers_server_vm.dart'
if (dart.library.js_interop) 'response_headers_server_web.dart';

/// Tests that the [Client] correctly processes response headers.
void testResponseHeaders(Client client) async {
void testResponseHeaders(Client client,
{bool canRelyOnContentLength = true}) async {
group('server headers', () {
late String host;
late StreamChannel<Object?> httpServerChannel;
Expand Down Expand Up @@ -151,7 +152,9 @@ void testResponseHeaders(Client client) async {
httpServerChannel.sink.add('content-length: 100\r\n');
await expectLater(
client.get(Uri.http(host, '')), throwsA(isA<ClientException>()));
});
},
skip:
canRelyOnContentLength ? false : 'cannot rely on content length');
});

group('folded headers', () {
Expand Down