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

Side by Side Diff: runtime/bin/http_parser.dart

Issue 10911120: Cleanup and fixes to some dart:io files (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 3 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
« no previous file with comments | « runtime/bin/http.dart ('k') | runtime/bin/string_stream.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 515 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 _reset(); 526 _reset();
527 } else { 527 } else {
528 _state = _State.CHUNK_SIZE_STARTING_CR; 528 _state = _State.CHUNK_SIZE_STARTING_CR;
529 } 529 }
530 } 530 }
531 531
532 // Hack - as we always do index++ below. 532 // Hack - as we always do index++ below.
533 index--; 533 index--;
534 break; 534 break;
535 535
536 case _state = _State.FAILURE: 536 case _State.FAILURE:
537 // Should be unreachable. 537 // Should be unreachable.
538 assert(false); 538 assert(false);
539 break; 539 break;
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 (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
561 // Return the number of bytes parsed. 561 // Return the number of bytes parsed.
562 return index - offset; 562 return index - offset;
563 } 563 }
564 564
565 int connectionClosed() { 565 void connectionClosed() {
566 if (_state < _State.FIRST_BODY_STATE) { 566 if (_state < _State.FIRST_BODY_STATE) {
567 _state = _State.FAILURE; 567 _state = _State.FAILURE;
568 // Report the error through the error callback if any. Otherwise 568 // Report the error through the error callback if any. Otherwise
569 // throw the error. 569 // throw the error.
570 var e = new HttpParserException( 570 var e = new HttpParserException(
571 "Connection closed before full header was received"); 571 "Connection closed before full header was received");
572 if (error != null) { 572 if (error != null) {
573 error(e); 573 error(e);
574 return; 574 return;
575 } 575 }
(...skipping 16 matching lines...) Expand all
592 return; 592 return;
593 } 593 }
594 throw e; 594 throw e;
595 } 595 }
596 } 596 }
597 597
598 String get version { 598 String get version {
599 switch (_httpVersion) { 599 switch (_httpVersion) {
600 case _HttpVersion.HTTP10: 600 case _HttpVersion.HTTP10:
601 return "1.0"; 601 return "1.0";
602 break;
603 case _HttpVersion.HTTP11: 602 case _HttpVersion.HTTP11:
604 return "1.1"; 603 return "1.1";
605 break;
606 } 604 }
607 return null; 605 return null;
608 } 606 }
609 607
610 int get messageType => _messageType; 608 int get messageType => _messageType;
611 int get contentLength => _contentLength; 609 int get contentLength => _contentLength;
612 bool get upgrade => _connectionUpgrade && _state == _State.UPGRADED; 610 bool get upgrade => _connectionUpgrade && _state == _State.UPGRADED;
613 bool get persistentConnection => _persistentConnection; 611 bool get persistentConnection => _persistentConnection;
614 612
615 void set responseToMethod(String method) { _responseToMethod = method; } 613 void set responseToMethod(String method) { _responseToMethod = method; }
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
717 Function dataEnd; 715 Function dataEnd;
718 Function error; 716 Function error;
719 } 717 }
720 718
721 719
722 class HttpParserException implements Exception { 720 class HttpParserException implements Exception {
723 const HttpParserException([String this.message = ""]); 721 const HttpParserException([String this.message = ""]);
724 String toString() => "HttpParserException: $message"; 722 String toString() => "HttpParserException: $message";
725 final String message; 723 final String message;
726 } 724 }
OLDNEW
« no previous file with comments | « runtime/bin/http.dart ('k') | runtime/bin/string_stream.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698