| 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 part of dart.io; | 5 part of dart.io; |
| 6 | 6 |
| 7 // Global constants. | 7 // Global constants. |
| 8 class _Const { | 8 class _Const { |
| 9 // Bytes for "HTTP". | 9 // Bytes for "HTTP". |
| 10 static const HTTP = const [72, 84, 84, 80]; | 10 static const HTTP = const [72, 84, 84, 80]; |
| (...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 508 _messageType = _MessageType.REQUEST; | 508 _messageType = _MessageType.REQUEST; |
| 509 _state = _State.HEADER_START; | 509 _state = _State.HEADER_START; |
| 510 break; | 510 break; |
| 511 | 511 |
| 512 case _State.RESPONSE_LINE_STATUS_CODE: | 512 case _State.RESPONSE_LINE_STATUS_CODE: |
| 513 if (byte == _CharCode.SP) { | 513 if (byte == _CharCode.SP) { |
| 514 if (_method_or_status_code.length != 3) { | 514 if (_method_or_status_code.length != 3) { |
| 515 throw new HttpException("Invalid response status code"); | 515 throw new HttpException("Invalid response status code"); |
| 516 } | 516 } |
| 517 _state = _State.RESPONSE_LINE_REASON_PHRASE; | 517 _state = _State.RESPONSE_LINE_REASON_PHRASE; |
| 518 } else if (byte == _CharCode.CR) { |
| 519 // Some HTTP servers does not follow the spec. and send |
| 520 // \r\n right after the status code. |
| 521 _state = _State.RESPONSE_LINE_ENDING; |
| 518 } else { | 522 } else { |
| 519 if (byte < 0x30 && 0x39 < byte) { | 523 if (byte < 0x30 && 0x39 < byte) { |
| 520 throw new HttpException("Invalid response status code"); | 524 throw new HttpException("Invalid response status code"); |
| 521 } else { | 525 } else { |
| 522 _method_or_status_code.add(byte); | 526 _method_or_status_code.add(byte); |
| 523 } | 527 } |
| 524 } | 528 } |
| 525 break; | 529 break; |
| 526 | 530 |
| 527 case _State.RESPONSE_LINE_REASON_PHRASE: | 531 case _State.RESPONSE_LINE_REASON_PHRASE: |
| (...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1036 } | 1040 } |
| 1037 } | 1041 } |
| 1038 | 1042 |
| 1039 void _reportError(error, [stackTrace]) { | 1043 void _reportError(error, [stackTrace]) { |
| 1040 if (_socketSubscription != null) _socketSubscription.cancel(); | 1044 if (_socketSubscription != null) _socketSubscription.cancel(); |
| 1041 _state = _State.FAILURE; | 1045 _state = _State.FAILURE; |
| 1042 _controller.addError(error, stackTrace); | 1046 _controller.addError(error, stackTrace); |
| 1043 _controller.close(); | 1047 _controller.close(); |
| 1044 } | 1048 } |
| 1045 } | 1049 } |
| OLD | NEW |