| 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 'dart:async'; | 5 import 'dart:async'; |
| 6 import 'dart:math'; | 6 import 'dart:math'; |
| 7 | 7 |
| 8 part '../../../sdk/lib/io/io_stream_consumer.dart'; | 8 part '../../../sdk/lib/io/io_stream_consumer.dart'; |
| 9 part "../../../sdk/lib/io/http.dart"; | 9 part "../../../sdk/lib/io/http.dart"; |
| 10 part "../../../sdk/lib/io/http_impl.dart"; | 10 part "../../../sdk/lib/io/http_impl.dart"; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 parser.partDataReceived = (List<int> data) { | 40 parser.partDataReceived = (List<int> data) { |
| 41 if (currentPart == null) currentPart = new List<int>(); | 41 if (currentPart == null) currentPart = new List<int>(); |
| 42 currentPart.addAll(data); | 42 currentPart.addAll(data); |
| 43 }; | 43 }; |
| 44 parser.partEnd = (lastPart) { | 44 parser.partEnd = (lastPart) { |
| 45 Expect.isFalse(lastPartCalled); | 45 Expect.isFalse(lastPartCalled); |
| 46 lastPartCalled = lastPart; | 46 lastPartCalled = lastPart; |
| 47 if (expectedParts[partCount] != null) { | 47 if (expectedParts[partCount] != null) { |
| 48 List<int> expectedPart; | 48 List<int> expectedPart; |
| 49 if (expectedParts[partCount] is String) { | 49 if (expectedParts[partCount] is String) { |
| 50 expectedPart = expectedParts[partCount].charCodes; | 50 expectedPart = expectedParts[partCount].codeUnits; |
| 51 } else { | 51 } else { |
| 52 expectedPart = expectedParts[partCount]; | 52 expectedPart = expectedParts[partCount]; |
| 53 } | 53 } |
| 54 Expect.listEquals(expectedPart, currentPart); | 54 Expect.listEquals(expectedPart, currentPart); |
| 55 } | 55 } |
| 56 currentPart = null; | 56 currentPart = null; |
| 57 partCount++; | 57 partCount++; |
| 58 if (lastPart) Expect.equals(expectedParts.length, partCount); | 58 if (lastPart) Expect.equals(expectedParts.length, partCount); |
| 59 }; | 59 }; |
| 60 | 60 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 76 int parsed = | 76 int parsed = |
| 77 parser.update(data.getRange(pos, writeLength), 0, writeLength); | 77 parser.update(data.getRange(pos, writeLength), 0, writeLength); |
| 78 unparsed = writeLength - parsed; | 78 unparsed = writeLength - parsed; |
| 79 Expect.equals(0, unparsed); | 79 Expect.equals(0, unparsed); |
| 80 } | 80 } |
| 81 Expect.isTrue(lastPartCalled); | 81 Expect.isTrue(lastPartCalled); |
| 82 } | 82 } |
| 83 | 83 |
| 84 // Test parsing the data three times delivering the data in | 84 // Test parsing the data three times delivering the data in |
| 85 // different chunks. | 85 // different chunks. |
| 86 List<int> data = message.charCodes; | 86 List<int> data = message.codeUnits; |
| 87 testWrite(data); | 87 testWrite(data); |
| 88 testWrite(data, 10); | 88 testWrite(data, 10); |
| 89 testWrite(data, 2); | 89 testWrite(data, 2); |
| 90 testWrite(data, 1); | 90 testWrite(data, 1); |
| 91 } | 91 } |
| 92 | 92 |
| 93 void testParseValid() { | 93 void testParseValid() { |
| 94 String message; | 94 String message; |
| 95 Map headers; | 95 Map headers; |
| 96 Map headers1; | 96 Map headers1; |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 \r | 336 \r |
| 337 Body2\r | 337 Body2\r |
| 338 --xxx\r\n"""; | 338 --xxx\r\n"""; |
| 339 Expect.throws(() => testParse(message, "xxx", null, [null, null])); | 339 Expect.throws(() => testParse(message, "xxx", null, [null, null])); |
| 340 } | 340 } |
| 341 | 341 |
| 342 void main() { | 342 void main() { |
| 343 testParseValid(); | 343 testParseValid(); |
| 344 testParseInvalid(); | 344 testParseInvalid(); |
| 345 } | 345 } |
| OLD | NEW |