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

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

Issue 1017453008: Make GetAlternateProtocol return AlternativeService. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: s/server/origin/g in other methods too. Created 5 years, 9 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
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"
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 179
180 if (!session_->params().use_alternate_protocols) 180 if (!session_->params().use_alternate_protocols)
181 return kNoAlternativeService; 181 return kNoAlternativeService;
182 182
183 if (original_url.SchemeIs("ftp")) 183 if (original_url.SchemeIs("ftp"))
184 return kNoAlternativeService; 184 return kNoAlternativeService;
185 185
186 HostPortPair origin = HostPortPair::FromURL(original_url); 186 HostPortPair origin = HostPortPair::FromURL(original_url);
187 HttpServerProperties& http_server_properties = 187 HttpServerProperties& http_server_properties =
188 *session_->http_server_properties(); 188 *session_->http_server_properties();
189 const AlternateProtocolInfo alternate = 189 const AlternativeService alternative_service =
190 http_server_properties.GetAlternateProtocol(origin); 190 http_server_properties.GetAlternativeService(origin);
191 191
192 if (alternate.protocol == UNINITIALIZED_ALTERNATE_PROTOCOL) 192 if (alternative_service.protocol == UNINITIALIZED_ALTERNATE_PROTOCOL)
193 return kNoAlternativeService; 193 return kNoAlternativeService;
194 const AlternativeService alternative_service(alternate.protocol, 194 // TODO(bnc): Make sure that callers connect to the specified host, and that
195 origin.host(), alternate.port); 195 // certificate requirements are enforced. Then remove the following two
196 // lines.
197 if (alternative_service.host != origin.host())
198 return kNoAlternativeService;
196 if (http_server_properties.IsAlternativeServiceBroken(alternative_service)) { 199 if (http_server_properties.IsAlternativeServiceBroken(alternative_service)) {
197 HistogramAlternateProtocolUsage(ALTERNATE_PROTOCOL_USAGE_BROKEN); 200 HistogramAlternateProtocolUsage(ALTERNATE_PROTOCOL_USAGE_BROKEN);
198 return kNoAlternativeService; 201 return kNoAlternativeService;
199 } 202 }
200 if (!IsAlternateProtocolValid(alternate.protocol)) { 203 if (!IsAlternateProtocolValid(alternative_service.protocol)) {
201 NOTREACHED(); 204 NOTREACHED();
202 return kNoAlternativeService; 205 return kNoAlternativeService;
203 } 206 }
204 207
205 // Some shared unix systems may have user home directories (like 208 // Some shared unix systems may have user home directories (like
206 // http://foo.com/~mike) which allow users to emit headers. This is a bad 209 // http://foo.com/~mike) which allow users to emit headers. This is a bad
207 // idea already, but with Alternate-Protocol, it provides the ability for a 210 // idea already, but with Alternate-Protocol, it provides the ability for a
208 // single user on a multi-user system to hijack the alternate protocol. 211 // single user on a multi-user system to hijack the alternate protocol.
209 // These systems also enforce ports <1024 as restricted ports. So don't 212 // These systems also enforce ports <1024 as restricted ports. So don't
210 // allow protocol upgrades to user-controllable ports. 213 // allow protocol upgrades to user-controllable ports.
211 const int kUnrestrictedPort = 1024; 214 const int kUnrestrictedPort = 1024;
212 if (!session_->params().enable_user_alternate_protocol_ports && 215 if (!session_->params().enable_user_alternate_protocol_ports &&
213 (alternate.port >= kUnrestrictedPort && 216 (alternative_service.port >= kUnrestrictedPort &&
214 origin.port() < kUnrestrictedPort)) 217 origin.port() < kUnrestrictedPort))
215 return kNoAlternativeService; 218 return kNoAlternativeService;
216 219
217 origin.set_port(alternate.port); 220 origin.set_port(alternative_service.port);
218 if (alternate.protocol >= NPN_SPDY_MINIMUM_VERSION && 221 if (alternative_service.protocol >= NPN_SPDY_MINIMUM_VERSION &&
219 alternate.protocol <= NPN_SPDY_MAXIMUM_VERSION) { 222 alternative_service.protocol <= NPN_SPDY_MAXIMUM_VERSION) {
220 if (!HttpStreamFactory::spdy_enabled()) 223 if (!HttpStreamFactory::spdy_enabled())
221 return kNoAlternativeService; 224 return kNoAlternativeService;
222 225
223 if (session_->HasSpdyExclusion(origin)) 226 if (session_->HasSpdyExclusion(origin))
224 return kNoAlternativeService; 227 return kNoAlternativeService;
225 228
226 *alternate_url = UpgradeUrlToHttps(original_url, alternate.port); 229 *alternate_url = UpgradeUrlToHttps(original_url, alternative_service.port);
227 } else { 230 } else {
228 DCHECK_EQ(QUIC, alternate.protocol); 231 DCHECK_EQ(QUIC, alternative_service.protocol);
229 if (!session_->params().enable_quic) 232 if (!session_->params().enable_quic)
230 return kNoAlternativeService; 233 return kNoAlternativeService;
231 234
232 // TODO(rch): Figure out how to make QUIC iteract with PAC 235 // TODO(rch): Figure out how to make QUIC iteract with PAC
233 // scripts. By not re-writing the URL, we will query the PAC script 236 // scripts. By not re-writing the URL, we will query the PAC script
234 // for the proxy to use to reach the original URL via TCP. But 237 // for the proxy to use to reach the original URL via TCP. But
235 // the alternate request will be going via UDP to a different port. 238 // the alternate request will be going via UDP to a different port.
236 *alternate_url = original_url; 239 *alternate_url = original_url;
237 } 240 }
238 return AlternativeService(alternate.protocol, origin.host(), alternate.port); 241 return alternative_service;
239 } 242 }
240 243
241 void HttpStreamFactoryImpl::OrphanJob(Job* job, const Request* request) { 244 void HttpStreamFactoryImpl::OrphanJob(Job* job, const Request* request) {
242 DCHECK(ContainsKey(request_map_, job)); 245 DCHECK(ContainsKey(request_map_, job));
243 DCHECK_EQ(request_map_[job], request); 246 DCHECK_EQ(request_map_[job], request);
244 DCHECK(!ContainsKey(orphaned_job_set_, job)); 247 DCHECK(!ContainsKey(orphaned_job_set_, job));
245 248
246 request_map_.erase(job); 249 request_map_.erase(job);
247 250
248 orphaned_job_set_.insert(job); 251 orphaned_job_set_.insert(job);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 delete job; 300 delete job;
298 } 301 }
299 302
300 void HttpStreamFactoryImpl::OnPreconnectsComplete(const Job* job) { 303 void HttpStreamFactoryImpl::OnPreconnectsComplete(const Job* job) {
301 preconnect_job_set_.erase(job); 304 preconnect_job_set_.erase(job);
302 delete job; 305 delete job;
303 OnPreconnectsCompleteInternal(); 306 OnPreconnectsCompleteInternal();
304 } 307 }
305 308
306 } // namespace net 309 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_server_properties_manager_unittest.cc ('k') | net/quic/quic_network_transaction_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698