Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(525)

Unified Diff: tests/standalone/io/http_no_reason_phrase_test.dart

Issue 169723003: Allow HTTP response without reason phrase (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sdk/lib/io/http_parser.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/standalone/io/http_no_reason_phrase_test.dart
diff --git a/tests/standalone/io/http_no_reason_phrase_test.dart b/tests/standalone/io/http_no_reason_phrase_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..9db6a643a4b83e3b2d7e2c2b46ee345e9d859f8b
--- /dev/null
+++ b/tests/standalone/io/http_no_reason_phrase_test.dart
@@ -0,0 +1,42 @@
+// (c) 2014, 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.
+
+// VMOptions=
+// VMOptions=--short_socket_read
+// VMOptions=--short_socket_write
+// VMOptions=--short_socket_read --short_socket_write
+
+import "package:expect/expect.dart";
+import "dart:async";
+import "dart:isolate";
+import "dart:io";
+
+// Test that a response line without any reason phrase is handled.
+void missingReasonPhrase(int statusCode, bool includeSpace) {
+ var client = new HttpClient();
+ ServerSocket.bind("127.0.0.1", 0).then((server) {
+ server.listen((client) {
+ if (includeSpace) {
+ client.write("HTTP/1.1 $statusCode \r\n\r\n");
+ } else {
+ client.write("HTTP/1.1 $statusCode\r\n\r\n");
+ }
+ client.close();
+ });
+ client.getUrl(Uri.parse("http://127.0.0.1:${server.port}/"))
+ .then((request) => request.close())
+ .then((response) {
+ Expect.equals(statusCode, response.statusCode);
+ Expect.equals("", response.reasonPhrase);
+ })
+ .whenComplete(() => server.close());
+ });
+}
+
+void main() {
+ missingReasonPhrase(HttpStatus.OK, true);
+ missingReasonPhrase(HttpStatus.INTERNAL_SERVER_ERROR, true);
+ missingReasonPhrase(HttpStatus.OK, false);
+ missingReasonPhrase(HttpStatus.INTERNAL_SERVER_ERROR, false);
+}
« no previous file with comments | « sdk/lib/io/http_parser.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698