| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 // Global constants. | 5 // Global constants. |
| 6 class _Const { | 6 class _Const { |
| 7 // Bytes for "HTTP". | 7 // Bytes for "HTTP". |
| 8 static const HTTP = const [72, 84, 84, 80]; | 8 static const HTTP = const [72, 84, 84, 80]; |
| 9 // Bytes for "HTTP/1.". | 9 // Bytes for "HTTP/1.". |
| 10 static const HTTP1DOT = const [72, 84, 84, 80, 47, 49, 46]; | 10 static const HTTP1DOT = const [72, 84, 84, 80, 47, 49, 46]; |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 } else { | 227 } else { |
| 228 if (_Const.SEPARATORS_AND_CR_LF.indexOf(byte) != -1) { | 228 if (_Const.SEPARATORS_AND_CR_LF.indexOf(byte) != -1) { |
| 229 throw new HttpParserException("Invalid request method"); | 229 throw new HttpParserException("Invalid request method"); |
| 230 } | 230 } |
| 231 _method_or_status_code.addCharCode(byte); | 231 _method_or_status_code.addCharCode(byte); |
| 232 } | 232 } |
| 233 break; | 233 break; |
| 234 | 234 |
| 235 case _State.REQUEST_LINE_URI: | 235 case _State.REQUEST_LINE_URI: |
| 236 if (byte == _CharCode.SP) { | 236 if (byte == _CharCode.SP) { |
| 237 if (_uri_or_reason_phrase.length == 0) { |
| 238 throw new HttpParserException("Invalid request URI"); |
| 239 } |
| 237 _state = _State.REQUEST_LINE_HTTP_VERSION; | 240 _state = _State.REQUEST_LINE_HTTP_VERSION; |
| 238 _httpVersionIndex = 0; | 241 _httpVersionIndex = 0; |
| 239 } else { | 242 } else { |
| 240 if (byte == _CharCode.CR || byte == _CharCode.LF) { | 243 if (byte == _CharCode.CR || byte == _CharCode.LF) { |
| 241 throw new HttpParserException("Invalid request URI"); | 244 throw new HttpParserException("Invalid request URI"); |
| 242 } | 245 } |
| 243 _uri_or_reason_phrase.addCharCode(byte); | 246 _uri_or_reason_phrase.addCharCode(byte); |
| 244 } | 247 } |
| 245 break; | 248 break; |
| 246 | 249 |
| (...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 715 Function dataEnd; | 718 Function dataEnd; |
| 716 Function error; | 719 Function error; |
| 717 } | 720 } |
| 718 | 721 |
| 719 | 722 |
| 720 class HttpParserException implements Exception { | 723 class HttpParserException implements Exception { |
| 721 const HttpParserException([String this.message = ""]); | 724 const HttpParserException([String this.message = ""]); |
| 722 String toString() => "HttpParserException: $message"; | 725 String toString() => "HttpParserException: $message"; |
| 723 final String message; | 726 final String message; |
| 724 } | 727 } |
| OLD | NEW |