Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 // VMOptions= | 5 // VMOptions= |
| 6 // VMOptions=--short_socket_read | 6 // VMOptions=--short_socket_read |
| 7 // VMOptions=--short_socket_write | 7 // VMOptions=--short_socket_write |
| 8 // VMOptions=--short_socket_read --short_socket_write | 8 // VMOptions=--short_socket_read --short_socket_write |
| 9 | 9 |
| 10 import "package:expect/expect.dart"; | 10 import "package:expect/expect.dart"; |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 23 Expect.equals(-1, request.contentLength); | 23 Expect.equals(-1, request.contentLength); |
| 24 var response = request.response; | 24 var response = request.response; |
| 25 response.contentLength = 1; | 25 response.contentLength = 1; |
| 26 Expect.equals("1.0", request.protocolVersion); | 26 Expect.equals("1.0", request.protocolVersion); |
| 27 response.done | 27 response.done |
| 28 .then((_) => Expect.fail("Unexpected response completion")) | 28 .then((_) => Expect.fail("Unexpected response completion")) |
| 29 .catchError((error) => Expect.isTrue(error is HttpException)); | 29 .catchError((error) => Expect.isTrue(error is HttpException)); |
| 30 response.write("Z"); | 30 response.write("Z"); |
| 31 response.write("Z"); | 31 response.write("Z"); |
| 32 response.close(); | 32 response.close(); |
| 33 Expect.throws(() => response.write("x"), | 33 //Expect.throws(() => response.write("x"), |
|
Anders Johnsen
2013/05/08 13:11:47
Debug stuff in this file.
| |
| 34 (e) => e is StateError); | 34 // (e) => e is StateError); |
| 35 }, | 35 }, |
| 36 onError: (e) { | 36 onError: (e) { |
| 37 String msg = "Unexpected error $e"; | 37 String msg = "Unexpected error $e"; |
| 38 var trace = getAttachedStackTrace(e); | 38 var trace = getAttachedStackTrace(e); |
| 39 if (trace != null) msg += "\nStackTrace: $trace"; | 39 if (trace != null) msg += "\nStackTrace: $trace"; |
| 40 Expect.fail(msg); | 40 Expect.fail(msg); |
| 41 }); | 41 }); |
| 42 | 42 |
| 43 int count = 0; | 43 int count = 0; |
| 44 makeRequest() { | 44 makeRequest() { |
| 45 Socket.connect("127.0.0.1", server.port).then((socket) { | 45 Socket.connect("127.0.0.1", server.port).then((socket) { |
| 46 socket.write("GET / HTTP/1.0\r\n\r\n"); | 46 socket.write("GET / HTTP/1.0\r\n\r\n"); |
| 47 | 47 |
| 48 List<int> response = []; | 48 List<int> response = []; |
| 49 socket.listen( | 49 socket.listen( |
| 50 response.addAll, | 50 response.addAll, |
| 51 onDone: () { | 51 onDone: () { |
| 52 count++; | 52 count++; |
| 53 socket.destroy(); | 53 socket.destroy(); |
| 54 String s = new String.fromCharCodes(response).toLowerCase(); | 54 String s = new String.fromCharCodes(response).toLowerCase(); |
| 55 print("SSS [$s]"); | |
| 55 Expect.isTrue(s.indexOf("\r\ncontent-length: 1\r\n") > 0); | 56 Expect.isTrue(s.indexOf("\r\ncontent-length: 1\r\n") > 0); |
| 56 Expect.equals(-1, s.indexOf("keep-alive")); | 57 Expect.equals(-1, s.indexOf("keep-alive")); |
| 57 if (count < 10) { | 58 if (count < 2) { |
| 58 makeRequest(); | 59 makeRequest(); |
| 59 } else { | 60 } else { |
| 60 server.close(); | 61 server.close(); |
| 61 } | 62 } |
| 62 }); | 63 }, onError: ((e) => print("XXX $e")) |
| 64 ); | |
| 63 }); | 65 }); |
| 64 } | 66 } |
| 65 makeRequest(); | 67 makeRequest(); |
| 66 }); | 68 }); |
| 67 } | 69 } |
| 68 | 70 |
| 69 | 71 |
| 70 // Client makes a HTTP 1.0 request and the server does not set a | 72 // Client makes a HTTP 1.0 request and the server does not set a |
| 71 // content length so it has to close the connection to mark the end of | 73 // content length so it has to close the connection to mark the end of |
| 72 // the response. | 74 // the response. |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 225 }); | 227 }); |
| 226 } | 228 } |
| 227 | 229 |
| 228 | 230 |
| 229 void main() { | 231 void main() { |
| 230 testHttp10NoKeepAlive(); | 232 testHttp10NoKeepAlive(); |
| 231 testHttp10ServerClose(); | 233 testHttp10ServerClose(); |
| 232 testHttp10KeepAlive(); | 234 testHttp10KeepAlive(); |
| 233 testHttp10KeepAliveServerCloses(); | 235 testHttp10KeepAliveServerCloses(); |
| 234 } | 236 } |
| OLD | NEW |