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); |
+} |