Files
sdk/tests/standalone/io/http_parser_header_add_test.dart
T
Robert Nystrom a323c55162 Format tests/standalone/ using 3.8 style.
Change-Id: I4d492a63a41880ef8cd69321372a4853825b9efd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/426321
Reviewed-by: Liam Appelbe <liama@google.com>
Auto-Submit: Bob Nystrom <rnystrom@google.com>
Commit-Queue: Liam Appelbe <liama@google.com>
2025-05-04 17:45:09 -07:00

45 lines
1.3 KiB
Dart
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// 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";
// ignore: IMPORT_INTERNAL_LIBRARY
import "dart:_http" show TestingClass$_HttpHeaders, TestingClass$_HttpParser;
import "package:expect/async_helper.dart";
import "package:expect/expect.dart";
typedef _HttpParser = TestingClass$_HttpParser;
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();
});
// The character is U+2019 RIGHT SINGLE QUOTATION MARK.
final client = HttpClient()..userAgent = 'Bobs browser';
try {
await asyncExpectThrows<FormatException>(
client.open("CONNECT", "127.0.0.1", server.port, "/"),
);
} finally {
client.close(force: true);
server.close();
}
}
void testNullSubscriptionData() {
_HttpParser httpParser = new _HttpParser.requestParser();
httpParser.detachIncoming().listen((data) {}, onDone: () {});
}
main() {
asyncTest(testFormatException);
testNullSubscriptionData();
}