[dart:io] Stop accessing http header with _add()

Several places adds HttpHeader with _add() instead of public add(). This skips some validation checks.

Bug: https://github.com/dart-lang/sdk/issues/40905
Change-Id: Ifcb16fcd40fb93914540f6bf09f476f621c36e15
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/138860
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Zichang Guo <zichangguo@google.com>
This commit is contained in:
Zichang Guo 2020-03-18 18:10:55 +00:00 committed by commit-bot@chromium.org
parent 784b17dd24
commit 6a5b87f92c
4 changed files with 8 additions and 8 deletions

View file

@ -1760,9 +1760,9 @@ class _HttpClientConnection {
request.headers
..host = host
..port = port
.._add(HttpHeaders.acceptEncodingHeader, "gzip");
..add(HttpHeaders.acceptEncodingHeader, "gzip");
if (_httpClient.userAgent != null) {
request.headers._add(HttpHeaders.userAgentHeader, _httpClient.userAgent);
request.headers.add(HttpHeaders.userAgentHeader, _httpClient.userAgent);
}
if (proxy.isAuthenticated) {
// If the proxy configuration contains user information use that

View file

@ -680,10 +680,10 @@ class _HttpParser extends Stream<_HttpIncoming> {
(isUpgrade && isResponse && isUpgradeCode)) {
_connectionUpgrade = true;
}
_headers._add(headerField, tokens[i]);
_headers.add(headerField, tokens[i]);
}
} else {
_headers._add(headerField, headerValue);
_headers.add(headerField, headerValue);
}
_headerField.clear();
_headerValue.clear();

View file

@ -1758,9 +1758,9 @@ class _HttpClientConnection {
request.headers
..host = host
..port = port
.._add(HttpHeaders.acceptEncodingHeader, "gzip");
..add(HttpHeaders.acceptEncodingHeader, "gzip");
if (_httpClient.userAgent != null) {
request.headers._add(HttpHeaders.userAgentHeader, _httpClient.userAgent);
request.headers.add(HttpHeaders.userAgentHeader, _httpClient.userAgent!);
}
if (proxy.isAuthenticated) {
// If the proxy configuration contains user information use that

View file

@ -680,10 +680,10 @@ class _HttpParser extends Stream<_HttpIncoming> {
(isUpgrade && isResponse && isUpgradeCode)) {
_connectionUpgrade = true;
}
headers._add(headerField, tokens[i]);
headers.add(headerField, tokens[i]);
}
} else {
headers._add(headerField, headerValue);
headers.add(headerField, headerValue);
}
_headerField.clear();
_headerValue.clear();