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

Unified Diff: sdk/lib/io/http_parser.dart

Issue 2993873002: [dart:io] Ignore server http upgrade request unless status code is right (Closed)
Patch Set: Created 3 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sdk/lib/io/http.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/io/http_parser.dart
diff --git a/sdk/lib/io/http_parser.dart b/sdk/lib/io/http_parser.dart
index dc397c3c1782daadd86fc3219b86b5a488aaaff8..98c19d1f56996be48642e56d4c5e4b3820c7c252 100644
--- a/sdk/lib/io/http_parser.dart
+++ b/sdk/lib/io/http_parser.dart
@@ -664,9 +664,15 @@ class _HttpParser extends Stream<_HttpIncoming> {
}
if (headerField == "connection") {
List<String> tokens = _tokenizeFieldValue(headerValue);
+ final bool isResponse = _messageType == _MessageType.RESPONSE;
+ final bool isUpgradeCode =
+ _statusCode == HttpStatus.UPGRADE_REQUIRED ||
+ _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
for (int i = 0; i < tokens.length; i++) {
- if (_caseInsensitiveCompare(
- "upgrade".codeUnits, tokens[i].codeUnits)) {
+ final bool isUpgrade = _caseInsensitiveCompare(
+ "upgrade".codeUnits, tokens[i].codeUnits);
+ if ((isUpgrade && !isResponse) ||
+ (isUpgrade && isResponse && isUpgradeCode)) {
_connectionUpgrade = true;
}
_headers._add(headerField, tokens[i]);
« no previous file with comments | « sdk/lib/io/http.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698