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

Side by Side Diff: net/http/http_stream_factory_impl.cc

Issue 903273002: Update from https://crrev.com/315085 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 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
« no previous file with comments | « net/http/http_stream_factory.cc ('k') | net/http/http_stream_factory_impl_job.cc » ('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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/http/http_stream_factory_impl.h" 5 #include "net/http/http_stream_factory_impl.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
11 #include "base/strings/string_number_conversions.h" 11 #include "base/strings/string_number_conversions.h"
12 #include "net/base/net_log.h" 12 #include "net/base/net_log.h"
13 #include "net/base/net_util.h" 13 #include "net/base/net_util.h"
14 #include "net/http/http_network_session.h" 14 #include "net/http/http_network_session.h"
15 #include "net/http/http_server_properties.h" 15 #include "net/http/http_server_properties.h"
16 #include "net/http/http_stream_factory_impl_job.h" 16 #include "net/http/http_stream_factory_impl_job.h"
17 #include "net/http/http_stream_factory_impl_request.h" 17 #include "net/http/http_stream_factory_impl_request.h"
18 #include "net/spdy/spdy_http_stream.h" 18 #include "net/spdy/spdy_http_stream.h"
19 #include "url/gurl.h" 19 #include "url/gurl.h"
20 20
21 namespace net { 21 namespace net {
22 22
23 namespace { 23 namespace {
24 24
25 GURL UpgradeUrlToHttps(const GURL& original_url, int port) { 25 GURL UpgradeUrlToHttps(const GURL& original_url, int port) {
26 GURL::Replacements replacements; 26 GURL::Replacements replacements;
27 // new_sheme and new_port need to be in scope here because GURL::Replacements 27 // new_port needs to be in scope here because GURL::Replacements references
28 // references the memory contained by them directly. 28 // the memory contained by it directly.
29 const std::string new_scheme = "https";
30 const std::string new_port = base::IntToString(port); 29 const std::string new_port = base::IntToString(port);
31 replacements.SetSchemeStr(new_scheme); 30 replacements.SetSchemeStr("https");
32 replacements.SetPortStr(new_port); 31 replacements.SetPortStr(new_port);
33 return original_url.ReplaceComponents(replacements); 32 return original_url.ReplaceComponents(replacements);
34 } 33 }
35 34
36 } // namespace 35 } // namespace
37 36
38 HttpStreamFactoryImpl::HttpStreamFactoryImpl(HttpNetworkSession* session, 37 HttpStreamFactoryImpl::HttpStreamFactoryImpl(HttpNetworkSession* session,
39 bool for_websockets) 38 bool for_websockets)
40 : session_(session), 39 : session_(session),
41 for_websockets_(for_websockets) {} 40 for_websockets_(for_websockets) {}
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 job->Preconnect(num_streams); 167 job->Preconnect(num_streams);
169 } 168 }
170 169
171 const HostMappingRules* HttpStreamFactoryImpl::GetHostMappingRules() const { 170 const HostMappingRules* HttpStreamFactoryImpl::GetHostMappingRules() const {
172 return session_->params().host_mapping_rules; 171 return session_->params().host_mapping_rules;
173 } 172 }
174 173
175 AlternateProtocolInfo HttpStreamFactoryImpl::GetAlternateProtocolRequestFor( 174 AlternateProtocolInfo HttpStreamFactoryImpl::GetAlternateProtocolRequestFor(
176 const GURL& original_url, 175 const GURL& original_url,
177 GURL* alternate_url) { 176 GURL* alternate_url) {
178 const AlternateProtocolInfo kNoAlternateProtocol = 177 const AlternateProtocolInfo kNoAlternateProtocol;
179 AlternateProtocolInfo(0, UNINITIALIZED_ALTERNATE_PROTOCOL, 0);
180 178
181 if (!session_->params().use_alternate_protocols) 179 if (!session_->params().use_alternate_protocols)
182 return kNoAlternateProtocol; 180 return kNoAlternateProtocol;
183 181
184 if (original_url.SchemeIs("ftp")) 182 if (original_url.SchemeIs("ftp"))
185 return kNoAlternateProtocol; 183 return kNoAlternateProtocol;
186 184
187 HostPortPair origin = HostPortPair::FromURL(original_url); 185 HostPortPair origin = HostPortPair::FromURL(original_url);
188
189 HttpServerProperties& http_server_properties = 186 HttpServerProperties& http_server_properties =
190 *session_->http_server_properties(); 187 *session_->http_server_properties();
191 if (!http_server_properties.HasAlternateProtocol(origin)) 188 const AlternateProtocolInfo alternate =
189 http_server_properties.GetAlternateProtocol(origin);
190
191 if (alternate.protocol == UNINITIALIZED_ALTERNATE_PROTOCOL)
192 return kNoAlternateProtocol; 192 return kNoAlternateProtocol;
193
194 AlternateProtocolInfo alternate =
195 http_server_properties.GetAlternateProtocol(origin);
196 if (alternate.is_broken) { 193 if (alternate.is_broken) {
197 HistogramAlternateProtocolUsage(ALTERNATE_PROTOCOL_USAGE_BROKEN); 194 HistogramAlternateProtocolUsage(ALTERNATE_PROTOCOL_USAGE_BROKEN);
198 return kNoAlternateProtocol; 195 return kNoAlternateProtocol;
199 } 196 }
200
201 if (!IsAlternateProtocolValid(alternate.protocol)) { 197 if (!IsAlternateProtocolValid(alternate.protocol)) {
202 NOTREACHED(); 198 NOTREACHED();
203 return kNoAlternateProtocol; 199 return kNoAlternateProtocol;
204 } 200 }
205 201
206 // Some shared unix systems may have user home directories (like 202 // Some shared unix systems may have user home directories (like
207 // http://foo.com/~mike) which allow users to emit headers. This is a bad 203 // http://foo.com/~mike) which allow users to emit headers. This is a bad
208 // idea already, but with Alternate-Protocol, it provides the ability for a 204 // idea already, but with Alternate-Protocol, it provides the ability for a
209 // single user on a multi-user system to hijack the alternate protocol. 205 // single user on a multi-user system to hijack the alternate protocol.
210 // These systems also enforce ports <1024 as restricted ports. So don't 206 // These systems also enforce ports <1024 as restricted ports. So don't
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 delete job; 294 delete job;
299 } 295 }
300 296
301 void HttpStreamFactoryImpl::OnPreconnectsComplete(const Job* job) { 297 void HttpStreamFactoryImpl::OnPreconnectsComplete(const Job* job) {
302 preconnect_job_set_.erase(job); 298 preconnect_job_set_.erase(job);
303 delete job; 299 delete job;
304 OnPreconnectsCompleteInternal(); 300 OnPreconnectsCompleteInternal();
305 } 301 }
306 302
307 } // namespace net 303 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_stream_factory.cc ('k') | net/http/http_stream_factory_impl_job.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698