| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (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 import "package:expect/expect.dart"; | 5 import "package:expect/expect.dart"; |
| 6 import 'dart:async'; | 6 import 'dart:async'; |
| 7 import 'dart:math'; | 7 import 'dart:math'; |
| 8 import 'dart:typed_data'; | 8 import 'dart:typed_data'; |
| 9 import 'dart:isolate'; | 9 import 'dart:isolate'; |
| 10 import 'dart:collection'; | 10 import 'dart:collection'; |
| 11 | 11 |
| 12 part '../../../sdk/lib/io/common.dart'; | 12 part '../../../sdk/lib/io/common.dart'; |
| 13 part '../../../sdk/lib/io/io_sink.dart'; | 13 part '../../../sdk/lib/io/io_sink.dart'; |
| 14 part '../../../sdk/lib/io/http.dart'; | 14 part '../../../sdk/lib/io/http.dart'; |
| 15 part '../../../sdk/lib/io/http_date.dart'; |
| 15 part '../../../sdk/lib/io/http_impl.dart'; | 16 part '../../../sdk/lib/io/http_impl.dart'; |
| 16 part '../../../sdk/lib/io/http_headers.dart'; | 17 part '../../../sdk/lib/io/http_headers.dart'; |
| 17 part '../../../sdk/lib/io/http_parser.dart'; | 18 part '../../../sdk/lib/io/http_parser.dart'; |
| 18 part '../../../sdk/lib/io/socket.dart'; | 19 part '../../../sdk/lib/io/socket.dart'; |
| 19 | 20 |
| 20 class HttpParserTest { | 21 class HttpParserTest { |
| 21 static void runAllTests() { | 22 static void runAllTests() { |
| 22 testParseRequest(); | 23 testParseRequest(); |
| 23 testParseResponse(); | 24 testParseResponse(); |
| 24 testParseInvalidRequest(); | 25 testParseInvalidRequest(); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 38 String expectedVersion: "1.1"}) { | 39 String expectedVersion: "1.1"}) { |
| 39 StreamController controller; | 40 StreamController controller; |
| 40 void reset() { | 41 void reset() { |
| 41 _HttpParser httpParser = new _HttpParser.requestParser(); | 42 _HttpParser httpParser = new _HttpParser.requestParser(); |
| 42 controller = new StreamController(sync: true); | 43 controller = new StreamController(sync: true); |
| 43 var port1 = new ReceivePort(); | 44 var port1 = new ReceivePort(); |
| 44 var port2 = new ReceivePort(); | 45 var port2 = new ReceivePort(); |
| 45 | 46 |
| 46 String method; | 47 String method; |
| 47 Uri uri; | 48 Uri uri; |
| 48 HttpHeaders headers; | 49 _HttpHeaders headers; |
| 49 int contentLength; | 50 int contentLength; |
| 50 int bytesReceived; | 51 int bytesReceived; |
| 51 int unparsedBytesReceived; | 52 int unparsedBytesReceived; |
| 52 bool upgraded; | 53 bool upgraded; |
| 53 | 54 |
| 54 controller.stream.pipe(httpParser); | 55 controller.stream.pipe(httpParser); |
| 55 var subscription = httpParser.listen((incoming) { | 56 var subscription = httpParser.listen((incoming) { |
| 56 method = incoming.method; | 57 method = incoming.method; |
| 57 uri = incoming.uri; | 58 uri = incoming.uri; |
| 58 headers = incoming.headers; | 59 headers = incoming.headers; |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 StreamController controller; | 190 StreamController controller; |
| 190 bool upgraded; | 191 bool upgraded; |
| 191 | 192 |
| 192 void reset() { | 193 void reset() { |
| 193 _HttpParser httpParser; | 194 _HttpParser httpParser; |
| 194 bool headersCompleteCalled; | 195 bool headersCompleteCalled; |
| 195 bool dataEndCalled; | 196 bool dataEndCalled; |
| 196 bool dataEndClose; | 197 bool dataEndClose; |
| 197 int statusCode; | 198 int statusCode; |
| 198 String reasonPhrase; | 199 String reasonPhrase; |
| 199 HttpHeaders headers; | 200 _HttpHeaders headers; |
| 200 int contentLength; | 201 int contentLength; |
| 201 int bytesReceived; | 202 int bytesReceived; |
| 202 httpParser = new _HttpParser.responseParser(); | 203 httpParser = new _HttpParser.responseParser(); |
| 203 controller = new StreamController(sync: true); | 204 controller = new StreamController(sync: true); |
| 204 var port = new ReceivePort(); | 205 var port = new ReceivePort(); |
| 205 controller.stream.pipe(httpParser); | 206 controller.stream.pipe(httpParser); |
| 206 int doneCallCount = 0; | 207 int doneCallCount = 0; |
| 207 // Called when done parsing entire message and done parsing body. | 208 // Called when done parsing entire message and done parsing body. |
| 208 // Only executed when both are done. | 209 // Only executed when both are done. |
| 209 void whenDone() { | 210 void whenDone() { |
| (...skipping 662 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 872 0123456789012345678901234567890\r | 873 0123456789012345678901234567890\r |
| 873 0\r\n\r\n"""; | 874 0\r\n\r\n"""; |
| 874 _testParseInvalidResponse(response); | 875 _testParseInvalidResponse(response); |
| 875 } | 876 } |
| 876 } | 877 } |
| 877 | 878 |
| 878 | 879 |
| 879 void main() { | 880 void main() { |
| 880 HttpParserTest.runAllTests(); | 881 HttpParserTest.runAllTests(); |
| 881 } | 882 } |
| OLD | NEW |