Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(121)

Side by Side Diff: sdk/lib/io/http_parser.dart

Issue 11879042: Improve the error-propagation on socket streams (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, 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];
11 // Bytes for "HTTP/1.". 11 // Bytes for "HTTP/1.".
(...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after
625 _state = _State.FAILURE; 625 _state = _State.FAILURE;
626 // Report the error through the error callback if any. Otherwise 626 // Report the error through the error callback if any. Otherwise
627 // throw the error. 627 // throw the error.
628 error( 628 error(
629 new HttpParserException( 629 new HttpParserException(
630 "Connection closed before full ${type()} body was received")); 630 "Connection closed before full ${type()} body was received"));
631 } 631 }
632 } 632 }
633 633
634 void streamError(e) { 634 void streamError(e) {
635 // Don't report errors for a request parser when HTTP parser is in
636 // idle state. Clients can close the connection and cause a
637 // connection reset by peer error which is OK.
638 if (_requestParser && _state == _State.START) {
639 closed();
640 return;
641 }
642 error(e); 635 error(e);
643 } 636 }
644 637
645 String get version { 638 String get version {
646 switch (_httpVersion) { 639 switch (_httpVersion) {
647 case _HttpVersion.HTTP10: 640 case _HttpVersion.HTTP10:
648 return "1.0"; 641 return "1.0";
649 case _HttpVersion.HTTP11: 642 case _HttpVersion.HTTP11:
650 return "1.1"; 643 return "1.1";
651 } 644 }
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
785 Function error; 778 Function error;
786 Function closed; 779 Function closed;
787 } 780 }
788 781
789 782
790 class HttpParserException implements Exception { 783 class HttpParserException implements Exception {
791 const HttpParserException([String this.message = ""]); 784 const HttpParserException([String this.message = ""]);
792 String toString() => "HttpParserException: $message"; 785 String toString() => "HttpParserException: $message";
793 final String message; 786 final String message;
794 } 787 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698