eccff3bc4d
This is follow-up to https://dart.googlesource.com/sdk/+/60bea3003de2ea030a1970924d5af7b4a53f3a72. Issue: https://github.com/dart-lang/sdk/issues/44756 Change-Id: I3c76fe0d15e4aba26540a95c63ccba8480dc8315 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/180722 Reviewed-by: Alexander Aprelev <aam@google.com> Commit-Queue: Alexander Aprelev <aam@google.com>
38 lines
1.1 KiB
Dart
38 lines
1.1 KiB
Dart
// Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file
|
||
// for details. All rights reserved. Use of this source code is governed by a
|
||
// BSD-style license that can be found in the LICENSE file.
|
||
//
|
||
// Verify that FormatException is thrown when HttpClient userAgent has
|
||
// invalid value.
|
||
|
||
import "dart:async";
|
||
import "dart:io";
|
||
import "package:async_helper/async_helper.dart";
|
||
import "package:expect/expect.dart";
|
||
|
||
Future<void> testFormatException() async {
|
||
final server = await HttpServer.bind("127.0.0.1", 0);
|
||
server.listen((HttpRequest request) {
|
||
request.response.statusCode = 200;
|
||
request.response.close();
|
||
});
|
||
|
||
final completer = Completer<void>();
|
||
// The ’ character is U+2019 RIGHT SINGLE QUOTATION MARK.
|
||
final client = HttpClient()..userAgent = 'Bob’s browser';
|
||
asyncExpectThrows<FormatException>(() async {
|
||
try {
|
||
await client.open("CONNECT", "127.0.0.1", server.port, "/");
|
||
} finally {
|
||
client.close(force: true);
|
||
server.close();
|
||
completer.complete();
|
||
}
|
||
});
|
||
await completer.future;
|
||
}
|
||
|
||
main() {
|
||
asyncTest(testFormatException);
|
||
}
|