OLD | NEW |
(Empty) | |
| 1 // (c) 2014, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 // VMOptions= |
| 6 // VMOptions=--short_socket_read |
| 7 // VMOptions=--short_socket_write |
| 8 // VMOptions=--short_socket_read --short_socket_write |
| 9 |
| 10 import "package:expect/expect.dart"; |
| 11 import "dart:async"; |
| 12 import "dart:isolate"; |
| 13 import "dart:io"; |
| 14 |
| 15 // Test that a response line without any reason phrase is handled. |
| 16 void missingReasonPhrase(int statusCode, bool includeSpace) { |
| 17 var client = new HttpClient(); |
| 18 ServerSocket.bind("127.0.0.1", 0).then((server) { |
| 19 server.listen((client) { |
| 20 if (includeSpace) { |
| 21 client.write("HTTP/1.1 $statusCode \r\n\r\n"); |
| 22 } else { |
| 23 client.write("HTTP/1.1 $statusCode\r\n\r\n"); |
| 24 } |
| 25 client.close(); |
| 26 }); |
| 27 client.getUrl(Uri.parse("http://127.0.0.1:${server.port}/")) |
| 28 .then((request) => request.close()) |
| 29 .then((response) { |
| 30 Expect.equals(statusCode, response.statusCode); |
| 31 Expect.equals("", response.reasonPhrase); |
| 32 }) |
| 33 .whenComplete(() => server.close()); |
| 34 }); |
| 35 } |
| 36 |
| 37 void main() { |
| 38 missingReasonPhrase(HttpStatus.OK, true); |
| 39 missingReasonPhrase(HttpStatus.INTERNAL_SERVER_ERROR, true); |
| 40 missingReasonPhrase(HttpStatus.OK, false); |
| 41 missingReasonPhrase(HttpStatus.INTERNAL_SERVER_ERROR, false); |
| 42 } |
OLD | NEW |