| 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/1.0". | 7 // Bytes for "HTTP/1.0". |
| 8 static final HTTP10 = const [72, 84, 84, 80, 47, 49, 46, 48]; | 8 static final HTTP10 = const [72, 84, 84, 80, 47, 49, 46, 48]; |
| 9 // Bytes for "HTTP/1.1". | 9 // Bytes for "HTTP/1.1". |
| 10 static final HTTP11 = const [72, 84, 84, 80, 47, 49, 46, 49]; | 10 static final HTTP11 = const [72, 84, 84, 80, 47, 49, 46, 49]; |
| (...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 498 | 498 |
| 499 int _expectHexDigit(int byte) { | 499 int _expectHexDigit(int byte) { |
| 500 if (0x30 <= byte && byte <= 0x39) { | 500 if (0x30 <= byte && byte <= 0x39) { |
| 501 return byte - 0x30; // 0 - 9 | 501 return byte - 0x30; // 0 - 9 |
| 502 } else if (0x41 <= byte && byte <= 0x46) { | 502 } else if (0x41 <= byte && byte <= 0x46) { |
| 503 return byte - 0x41 + 10; // A - F | 503 return byte - 0x41 + 10; // A - F |
| 504 } else if (0x61 <= byte && byte <= 0x66) { | 504 } else if (0x61 <= byte && byte <= 0x66) { |
| 505 return byte - 0x61 + 10; // a - f | 505 return byte - 0x61 + 10; // a - f |
| 506 } else { | 506 } else { |
| 507 throw new HttpParserException("Failed to parse HTTP"); | 507 throw new HttpParserException("Failed to parse HTTP"); |
| 508 return 0; | |
| 509 } | 508 } |
| 510 } | 509 } |
| 511 | 510 |
| 512 int _state; | 511 int _state; |
| 513 int _httpVersionIndex; | 512 int _httpVersionIndex; |
| 514 int _messageType; | 513 int _messageType; |
| 515 StringBuffer _method_or_status_code; | 514 StringBuffer _method_or_status_code; |
| 516 StringBuffer _uri_or_reason_phrase; | 515 StringBuffer _uri_or_reason_phrase; |
| 517 StringBuffer _headerField; | 516 StringBuffer _headerField; |
| 518 StringBuffer _headerValue; | 517 StringBuffer _headerValue; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 534 Function dataEnd; | 533 Function dataEnd; |
| 535 Function error; | 534 Function error; |
| 536 } | 535 } |
| 537 | 536 |
| 538 | 537 |
| 539 class HttpParserException implements Exception { | 538 class HttpParserException implements Exception { |
| 540 const HttpParserException([String this.message = ""]); | 539 const HttpParserException([String this.message = ""]); |
| 541 String toString() => "HttpParserException: $message"; | 540 String toString() => "HttpParserException: $message"; |
| 542 final String message; | 541 final String message; |
| 543 } | 542 } |
| OLD | NEW |