a323c55162
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>
32 lines
1.1 KiB
Dart
32 lines
1.1 KiB
Dart
// Copyright (c) 2022, 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 HttpClient open, openUrl method argument is validated.
|
|
|
|
import "dart:io";
|
|
import "package:expect/expect.dart";
|
|
|
|
void testInvalidArgumentException(String method) {
|
|
Expect.throws(
|
|
() => HttpClient()..open(method, "127.0.0.1", 8080, "/"),
|
|
(e) => e is ArgumentError,
|
|
);
|
|
Expect.throws(
|
|
() => HttpClient()..openUrl(method, Uri.parse("http://127.0.0.1/")),
|
|
(e) => e is ArgumentError,
|
|
);
|
|
}
|
|
|
|
main() {
|
|
const String separators = "\t\n\r()<>@,;:\\/[]?={}";
|
|
for (int i = 0; i < separators.length; i++) {
|
|
String separator = separators.substring(i, i + 1);
|
|
testInvalidArgumentException(separator);
|
|
testInvalidArgumentException(separator + "CONNECT");
|
|
testInvalidArgumentException("CONN" + separator + "ECT");
|
|
testInvalidArgumentException("CONN" + separator + separator + "ECT");
|
|
testInvalidArgumentException("CONNECT" + separator);
|
|
}
|
|
}
|