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

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

Issue 11453006: Fix a number of HTTP issues (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years 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) 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 612 matching lines...) Expand 10 before | Expand all | Expand 10 after
623 _state = _State.FAILURE; 623 _state = _State.FAILURE;
624 // Report the error through the error callback if any. Otherwise 624 // Report the error through the error callback if any. Otherwise
625 // throw the error. 625 // throw the error.
626 error( 626 error(
627 new HttpParserException( 627 new HttpParserException(
628 "Connection closed before full ${type()} body was received")); 628 "Connection closed before full ${type()} body was received"));
629 } 629 }
630 } 630 }
631 631
632 void streamError(e) { 632 void streamError(e) {
633 // Don't report errors when HTTP parser is in idle state. Clients 633 // Don't report errors for a request parser when HTTP parser is in
634 // can close the connection and cause a connection reset by peer 634 // idle state. Clients can close the connection and cause a
635 // error which is OK. 635 // connection reset by peer error which is OK.
636 if (_state == _State.START) { 636 if (_requestParser && _state == _State.START) {
637 closed(); 637 closed();
638 return; 638 return;
639 } 639 }
640 error(e); 640 error(e);
641 } 641 }
642 642
643 String get version { 643 String get version {
644 switch (_httpVersion) { 644 switch (_httpVersion) {
645 case _HttpVersion.HTTP10: 645 case _HttpVersion.HTTP10:
646 return "1.0"; 646 return "1.0";
647 case _HttpVersion.HTTP11: 647 case _HttpVersion.HTTP11:
648 return "1.1"; 648 return "1.1";
649 } 649 }
650 return null; 650 return null;
651 } 651 }
652 652
653 void cancel() { 653 void cancel() {
654 _state = _State.CANCELED; 654 _state = _State.CANCELED;
655 } 655 }
656 656
657 void restart() {
658 _reset();
659 }
660
657 int get messageType => _messageType; 661 int get messageType => _messageType;
658 int get contentLength => _contentLength; 662 int get contentLength => _contentLength;
659 bool get upgrade => _connectionUpgrade && _state == _State.UPGRADED; 663 bool get upgrade => _connectionUpgrade && _state == _State.UPGRADED;
660 bool get persistentConnection => _persistentConnection; 664 bool get persistentConnection => _persistentConnection;
661 665
662 void set responseToMethod(String method) { _responseToMethod = method; } 666 void set responseToMethod(String method) { _responseToMethod = method; }
663 667
664 List<int> readUnparsedData() { 668 List<int> readUnparsedData() {
665 if (_buffer == null) return []; 669 if (_buffer == null) return [];
666 if (_index == _lastIndex) return []; 670 if (_index == _lastIndex) return [];
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
781 Function error; 785 Function error;
782 Function closed; 786 Function closed;
783 } 787 }
784 788
785 789
786 class HttpParserException implements Exception { 790 class HttpParserException implements Exception {
787 const HttpParserException([String this.message = ""]); 791 const HttpParserException([String this.message = ""]);
788 String toString() => "HttpParserException: $message"; 792 String toString() => "HttpParserException: $message";
789 final String message; 793 final String message;
790 } 794 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698