Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 646 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 657 _state = _State.HEADER_VALUE_START; | 657 _state = _State.HEADER_VALUE_START; |
| 658 } else { | 658 } else { |
| 659 String headerField = new String.fromCharCodes(_headerField); | 659 String headerField = new String.fromCharCodes(_headerField); |
| 660 String headerValue = new String.fromCharCodes(_headerValue); | 660 String headerValue = new String.fromCharCodes(_headerValue); |
| 661 if (headerField == "transfer-encoding" && | 661 if (headerField == "transfer-encoding" && |
| 662 _caseInsensitiveCompare("chunked".codeUnits, _headerValue)) { | 662 _caseInsensitiveCompare("chunked".codeUnits, _headerValue)) { |
| 663 _chunked = true; | 663 _chunked = true; |
| 664 } | 664 } |
| 665 if (headerField == "connection") { | 665 if (headerField == "connection") { |
| 666 List<String> tokens = _tokenizeFieldValue(headerValue); | 666 List<String> tokens = _tokenizeFieldValue(headerValue); |
| 667 final bool isResponse = _messageType == _MessageType.RESPONSE; | |
| 668 final bool isUpgradeCode = | |
| 669 _statusCode == HttpStatus.UPGRADE_REQUIRED || | |
| 670 _statusCode == HttpStatus.SWITCHING_PROTOCOLS; | |
|
siva
2017/08/07 21:30:19
Not sure about Dart coding standards but would mak
zra
2017/08/07 22:09:04
Couldn't find any guidance in the style guide, but
| |
| 667 for (int i = 0; i < tokens.length; i++) { | 671 for (int i = 0; i < tokens.length; i++) { |
| 668 if (_caseInsensitiveCompare( | 672 final bool isUpgrade = _caseInsensitiveCompare( |
| 669 "upgrade".codeUnits, tokens[i].codeUnits)) { | 673 "upgrade".codeUnits, tokens[i].codeUnits); |
| 674 if ((isUpgrade && !isResponse) || | |
| 675 (isUpgrade && isResponse && isUpgradeCode)) { | |
| 670 _connectionUpgrade = true; | 676 _connectionUpgrade = true; |
| 671 } | 677 } |
| 672 _headers._add(headerField, tokens[i]); | 678 _headers._add(headerField, tokens[i]); |
| 673 } | 679 } |
| 674 } else { | 680 } else { |
| 675 _headers._add(headerField, headerValue); | 681 _headers._add(headerField, headerValue); |
| 676 } | 682 } |
| 677 _headerField.clear(); | 683 _headerField.clear(); |
| 678 _headerValue.clear(); | 684 _headerValue.clear(); |
| 679 | 685 |
| (...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1047 } | 1053 } |
| 1048 } | 1054 } |
| 1049 | 1055 |
| 1050 void _reportError(error, [stackTrace]) { | 1056 void _reportError(error, [stackTrace]) { |
| 1051 if (_socketSubscription != null) _socketSubscription.cancel(); | 1057 if (_socketSubscription != null) _socketSubscription.cancel(); |
| 1052 _state = _State.FAILURE; | 1058 _state = _State.FAILURE; |
| 1053 _controller.addError(error, stackTrace); | 1059 _controller.addError(error, stackTrace); |
| 1054 _controller.close(); | 1060 _controller.close(); |
| 1055 } | 1061 } |
| 1056 } | 1062 } |
| OLD | NEW |