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 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
540 | 540 |
541 default: | 541 default: |
542 // Should be unreachable. | 542 // Should be unreachable. |
543 assert(false); | 543 assert(false); |
544 break; | 544 break; |
545 } | 545 } |
546 | 546 |
547 // Move to the next byte. | 547 // Move to the next byte. |
548 index++; | 548 index++; |
549 } | 549 } |
550 } catch (var e) { | 550 } catch (e) { |
551 // Report the error through the error callback if any. Otherwise | 551 // Report the error through the error callback if any. Otherwise |
552 // throw the error. | 552 // throw the error. |
553 if (error != null) { | 553 if (error != null) { |
554 error(e); | 554 error(e); |
555 _state = _State.FAILURE; | 555 _state = _State.FAILURE; |
556 } else { | 556 } else { |
557 throw e; | 557 throw e; |
558 } | 558 } |
559 } | 559 } |
560 | 560 |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
717 Function dataEnd; | 717 Function dataEnd; |
718 Function error; | 718 Function error; |
719 } | 719 } |
720 | 720 |
721 | 721 |
722 class HttpParserException implements Exception { | 722 class HttpParserException implements Exception { |
723 const HttpParserException([String this.message = ""]); | 723 const HttpParserException([String this.message = ""]); |
724 String toString() => "HttpParserException: $message"; | 724 String toString() => "HttpParserException: $message"; |
725 final String message; | 725 final String message; |
726 } | 726 } |
OLD | NEW |