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

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

Issue 169723003: Allow HTTP response without reason phrase (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 10 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 | « no previous file | tests/standalone/io/http_no_reason_phrase_test.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) 2013, 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];
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 _messageType = _MessageType.REQUEST; 508 _messageType = _MessageType.REQUEST;
509 _state = _State.HEADER_START; 509 _state = _State.HEADER_START;
510 break; 510 break;
511 511
512 case _State.RESPONSE_LINE_STATUS_CODE: 512 case _State.RESPONSE_LINE_STATUS_CODE:
513 if (byte == _CharCode.SP) { 513 if (byte == _CharCode.SP) {
514 if (_method_or_status_code.length != 3) { 514 if (_method_or_status_code.length != 3) {
515 throw new HttpException("Invalid response status code"); 515 throw new HttpException("Invalid response status code");
516 } 516 }
517 _state = _State.RESPONSE_LINE_REASON_PHRASE; 517 _state = _State.RESPONSE_LINE_REASON_PHRASE;
518 } else if (byte == _CharCode.CR) {
519 // Some HTTP servers does not follow the spec. and send
520 // \r\n right after the status code.
521 _state = _State.RESPONSE_LINE_ENDING;
518 } else { 522 } else {
519 if (byte < 0x30 && 0x39 < byte) { 523 if (byte < 0x30 && 0x39 < byte) {
520 throw new HttpException("Invalid response status code"); 524 throw new HttpException("Invalid response status code");
521 } else { 525 } else {
522 _method_or_status_code.add(byte); 526 _method_or_status_code.add(byte);
523 } 527 }
524 } 528 }
525 break; 529 break;
526 530
527 case _State.RESPONSE_LINE_REASON_PHRASE: 531 case _State.RESPONSE_LINE_REASON_PHRASE:
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after
1036 } 1040 }
1037 } 1041 }
1038 1042
1039 void _reportError(error, [stackTrace]) { 1043 void _reportError(error, [stackTrace]) {
1040 if (_socketSubscription != null) _socketSubscription.cancel(); 1044 if (_socketSubscription != null) _socketSubscription.cancel();
1041 _state = _State.FAILURE; 1045 _state = _State.FAILURE;
1042 _controller.addError(error, stackTrace); 1046 _controller.addError(error, stackTrace);
1043 _controller.close(); 1047 _controller.close();
1044 } 1048 }
1045 } 1049 }
OLDNEW
« no previous file with comments | « no previous file | tests/standalone/io/http_no_reason_phrase_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698