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

Unified Diff: net/http/http_stream_factory.cc

Issue 2011983002: Remove |parse_alternative_service| flag. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 4 years, 7 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 | « net/http/http_stream_factory.h ('k') | net/http/http_stream_factory_impl_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/http/http_stream_factory.cc
diff --git a/net/http/http_stream_factory.cc b/net/http/http_stream_factory.cc
index b0f1780a7620451f77f997ea5c1930cc7769a020..e94e5fadc5e9523852fdca50ae604689b79b8e12 100644
--- a/net/http/http_stream_factory.cc
+++ b/net/http/http_stream_factory.cc
@@ -38,58 +38,12 @@ void HttpStreamFactory::ProcessAlternativeServices(
HttpNetworkSession* session,
const HttpResponseHeaders* headers,
const url::SchemeHostPort& http_server) {
- if (session->params().parse_alternative_services) {
- if (headers->HasHeader(kAlternativeServiceHeader)) {
- std::string alternative_service_str;
- headers->GetNormalizedHeader(kAlternativeServiceHeader,
- &alternative_service_str);
- ProcessAlternativeService(session->http_server_properties(),
- alternative_service_str, http_server, *session);
- }
- // If "Alt-Svc" is enabled, then ignore "Alternate-Protocol".
- return;
- }
-
- if (!headers->HasHeader(kAlternateProtocolHeader))
+ if (!headers->HasHeader(kAlternativeServiceHeader))
return;
- std::vector<std::string> alternate_protocol_values;
- size_t iter = 0;
- std::string alternate_protocol_str;
- while (headers->EnumerateHeader(&iter, kAlternateProtocolHeader,
- &alternate_protocol_str)) {
- base::TrimWhitespaceASCII(alternate_protocol_str, base::TRIM_ALL,
- &alternate_protocol_str);
- if (!alternate_protocol_str.empty()) {
- alternate_protocol_values.push_back(alternate_protocol_str);
- }
- }
-
- ProcessAlternateProtocol(session->http_server_properties(),
- alternate_protocol_values, http_server, *session);
-}
-
-GURL HttpStreamFactory::ApplyHostMappingRules(const GURL& url,
- HostPortPair* endpoint) {
- const HostMappingRules* mapping_rules = GetHostMappingRules();
- if (mapping_rules && mapping_rules->RewriteHost(endpoint)) {
- url::Replacements<char> replacements;
- const std::string port_str = base::UintToString(endpoint->port());
- replacements.SetPort(port_str.c_str(), url::Component(0, port_str.size()));
- replacements.SetHost(endpoint->host().c_str(),
- url::Component(0, endpoint->host().size()));
- return url.ReplaceComponents(replacements);
- }
- return url;
-}
-
-HttpStreamFactory::HttpStreamFactory() {}
-
-void HttpStreamFactory::ProcessAlternativeService(
- const base::WeakPtr<HttpServerProperties>& http_server_properties,
- base::StringPiece alternative_service_str,
- const url::SchemeHostPort& http_server,
- const HttpNetworkSession& session) {
+ std::string alternative_service_str;
+ headers->GetNormalizedHeader(kAlternativeServiceHeader,
+ &alternative_service_str);
SpdyAltSvcWireFormat::AlternativeServiceVector alternative_service_vector;
if (!SpdyAltSvcWireFormat::ParseHeaderFieldValue(
alternative_service_str, &alternative_service_vector)) {
@@ -104,14 +58,14 @@ void HttpStreamFactory::ProcessAlternativeService(
AlternateProtocol protocol =
AlternateProtocolFromString(alternative_service_entry.protocol_id);
if (!IsAlternateProtocolValid(protocol) ||
- !session.IsProtocolEnabled(protocol) ||
+ !session->IsProtocolEnabled(protocol) ||
!IsPortValid(alternative_service_entry.port)) {
continue;
}
// Check if QUIC version is supported.
if (protocol == QUIC && !alternative_service_entry.version.empty()) {
bool match_found = false;
- for (QuicVersion supported : session.params().quic_supported_versions) {
+ for (QuicVersion supported : session->params().quic_supported_versions) {
for (uint16_t advertised : alternative_service_entry.version) {
if (supported == advertised) {
match_found = true;
@@ -137,69 +91,26 @@ void HttpStreamFactory::ProcessAlternativeService(
alternative_service_info_vector.push_back(alternative_service_info);
}
- http_server_properties->SetAlternativeServices(
+ session->http_server_properties()->SetAlternativeServices(
RewriteHost(http_server), alternative_service_info_vector);
}
-void HttpStreamFactory::ProcessAlternateProtocol(
- const base::WeakPtr<HttpServerProperties>& http_server_properties,
- const std::vector<std::string>& alternate_protocol_values,
- const url::SchemeHostPort& http_server,
- const HttpNetworkSession& session) {
- AlternateProtocol protocol = UNINITIALIZED_ALTERNATE_PROTOCOL;
- int port = 0;
- bool is_valid = true;
- for (size_t i = 0; i < alternate_protocol_values.size(); ++i) {
- base::StringPiece alternate_protocol_str = alternate_protocol_values[i];
- if (base::StartsWith(alternate_protocol_str, "p=",
- base::CompareCase::SENSITIVE)) {
- // Ignore deprecated probability.
- continue;
- }
- std::vector<base::StringPiece> port_protocol_vector =
- base::SplitStringPiece(alternate_protocol_str, ":",
- base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
- if (port_protocol_vector.size() != 2) {
- DVLOG(1) << kAlternateProtocolHeader
- << " header has too many tokens: "
- << alternate_protocol_str;
- is_valid = false;
- break;
- }
-
- if (!ParseInt32(port_protocol_vector[0], ParseIntFormat::NON_NEGATIVE,
- &port) ||
- port == 0 || !IsPortValid(port)) {
- DVLOG(1) << kAlternateProtocolHeader
- << " header has unrecognizable port: "
- << port_protocol_vector[0];
- is_valid = false;
- break;
- }
-
- protocol = AlternateProtocolFromString(port_protocol_vector[1].as_string());
-
- if (IsAlternateProtocolValid(protocol) &&
- !session.IsProtocolEnabled(protocol)) {
- DVLOG(1) << kAlternateProtocolHeader
- << " header has unrecognized protocol: "
- << port_protocol_vector[1];
- is_valid = false;
- break;
- }
- }
-
- if (!is_valid || protocol == UNINITIALIZED_ALTERNATE_PROTOCOL) {
- http_server_properties->ClearAlternativeServices(http_server);
- return;
+GURL HttpStreamFactory::ApplyHostMappingRules(const GURL& url,
+ HostPortPair* endpoint) {
+ const HostMappingRules* mapping_rules = GetHostMappingRules();
+ if (mapping_rules && mapping_rules->RewriteHost(endpoint)) {
+ url::Replacements<char> replacements;
+ const std::string port_str = base::UintToString(endpoint->port());
+ replacements.SetPort(port_str.c_str(), url::Component(0, port_str.size()));
+ replacements.SetHost(endpoint->host().c_str(),
+ url::Component(0, endpoint->host().size()));
+ return url.ReplaceComponents(replacements);
}
-
- http_server_properties->SetAlternativeService(
- RewriteHost(http_server),
- AlternativeService(protocol, "", static_cast<uint16_t>(port)),
- base::Time::Now() + base::TimeDelta::FromDays(30));
+ return url;
}
+HttpStreamFactory::HttpStreamFactory() {}
+
url::SchemeHostPort HttpStreamFactory::RewriteHost(
const url::SchemeHostPort& server) {
HostPortPair host_port_pair(server.host(), server.port());
« no previous file with comments | « net/http/http_stream_factory.h ('k') | net/http/http_stream_factory_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698