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 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 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
321 if (byte == _CharCode.CR || byte == _CharCode.LF) { | 321 if (byte == _CharCode.CR || byte == _CharCode.LF) { |
322 throw new HttpParserException("Invalid response reason phrase"); | 322 throw new HttpParserException("Invalid response reason phrase"); |
323 } | 323 } |
324 _uri_or_reason_phrase.add(byte); | 324 _uri_or_reason_phrase.add(byte); |
325 } | 325 } |
326 break; | 326 break; |
327 | 327 |
328 case _State.RESPONSE_LINE_ENDING: | 328 case _State.RESPONSE_LINE_ENDING: |
329 _expect(byte, _CharCode.LF); | 329 _expect(byte, _CharCode.LF); |
330 _messageType == _MessageType.RESPONSE; | 330 _messageType == _MessageType.RESPONSE; |
331 _statusCode = parseInt( | 331 _statusCode = int.parse( |
332 new String.fromCharCodes(_method_or_status_code)); | 332 new String.fromCharCodes(_method_or_status_code)); |
333 if (_statusCode < 100 || _statusCode > 599) { | 333 if (_statusCode < 100 || _statusCode > 599) { |
334 throw new HttpParserException("Invalid response status code"); | 334 throw new HttpParserException("Invalid response status code"); |
335 } | 335 } |
336 _state = _State.HEADER_START; | 336 _state = _State.HEADER_START; |
337 break; | 337 break; |
338 | 338 |
339 case _State.HEADER_START: | 339 case _State.HEADER_START: |
340 if (byte == _CharCode.CR) { | 340 if (byte == _CharCode.CR) { |
341 _state = _State.HEADER_ENDING; | 341 _state = _State.HEADER_ENDING; |
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
785 Function error; | 785 Function error; |
786 Function closed; | 786 Function closed; |
787 } | 787 } |
788 | 788 |
789 | 789 |
790 class HttpParserException implements Exception { | 790 class HttpParserException implements Exception { |
791 const HttpParserException([String this.message = ""]); | 791 const HttpParserException([String this.message = ""]); |
792 String toString() => "HttpParserException: $message"; | 792 String toString() => "HttpParserException: $message"; |
793 final String message; | 793 final String message; |
794 } | 794 } |
OLD | NEW |