OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_request.h" | 5 #include "net/http/http_stream_request.h" |
6 | 6 |
7 #include "base/stl_util-inl.h" | 7 #include "base/stl_util-inl.h" |
8 #include "base/string_number_conversions.h" | 8 #include "base/string_number_conversions.h" |
9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
10 #include "base/stringprintf.h" | 10 #include "base/stringprintf.h" |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 const HttpResponseInfo& response, | 199 const HttpResponseInfo& response, |
200 HttpAuthController* auth_controller) { | 200 HttpAuthController* auth_controller) { |
201 delegate_->OnNeedsProxyAuth(response, auth_controller); | 201 delegate_->OnNeedsProxyAuth(response, auth_controller); |
202 } | 202 } |
203 | 203 |
204 void HttpStreamRequest::OnNeedsClientAuthCallback( | 204 void HttpStreamRequest::OnNeedsClientAuthCallback( |
205 SSLCertRequestInfo* cert_info) { | 205 SSLCertRequestInfo* cert_info) { |
206 delegate_->OnNeedsClientAuth(cert_info); | 206 delegate_->OnNeedsClientAuth(cert_info); |
207 } | 207 } |
208 | 208 |
| 209 void HttpStreamRequest::OnHttpsProxyTunnelResponseCallback( |
| 210 const HttpResponseInfo& response_info, |
| 211 HttpStream* stream) { |
| 212 delegate_->OnHttpsProxyTunnelResponse(response_info, stream); |
| 213 } |
| 214 |
209 void HttpStreamRequest::OnPreconnectsComplete(int result) { | 215 void HttpStreamRequest::OnPreconnectsComplete(int result) { |
210 preconnect_delegate_->OnPreconnectsComplete(this, result); | 216 preconnect_delegate_->OnPreconnectsComplete(this, result); |
211 } | 217 } |
212 | 218 |
213 void HttpStreamRequest::OnIOComplete(int result) { | 219 void HttpStreamRequest::OnIOComplete(int result) { |
214 RunLoop(result); | 220 RunLoop(result); |
215 } | 221 } |
216 | 222 |
217 int HttpStreamRequest::RunLoop(int result) { | 223 int HttpStreamRequest::RunLoop(int result) { |
218 result = DoLoop(result); | 224 result = DoLoop(result); |
(...skipping 27 matching lines...) Expand all Loading... |
246 switch (result) { | 252 switch (result) { |
247 case ERR_PROXY_AUTH_REQUESTED: | 253 case ERR_PROXY_AUTH_REQUESTED: |
248 { | 254 { |
249 DCHECK(connection_.get()); | 255 DCHECK(connection_.get()); |
250 DCHECK(connection_->socket()); | 256 DCHECK(connection_->socket()); |
251 DCHECK(establishing_tunnel_); | 257 DCHECK(establishing_tunnel_); |
252 | 258 |
253 HttpProxyClientSocket* http_proxy_socket = | 259 HttpProxyClientSocket* http_proxy_socket = |
254 static_cast<HttpProxyClientSocket*>(connection_->socket()); | 260 static_cast<HttpProxyClientSocket*>(connection_->socket()); |
255 const HttpResponseInfo* tunnel_auth_response = | 261 const HttpResponseInfo* tunnel_auth_response = |
256 http_proxy_socket->GetResponseInfo(); | 262 http_proxy_socket->GetConnectResponseInfo(); |
257 | 263 |
258 next_state_ = STATE_WAITING_USER_ACTION; | 264 next_state_ = STATE_WAITING_USER_ACTION; |
259 MessageLoop::current()->PostTask( | 265 MessageLoop::current()->PostTask( |
260 FROM_HERE, | 266 FROM_HERE, |
261 method_factory_.NewRunnableMethod( | 267 method_factory_.NewRunnableMethod( |
262 &HttpStreamRequest::OnNeedsProxyAuthCallback, | 268 &HttpStreamRequest::OnNeedsProxyAuthCallback, |
263 *tunnel_auth_response, | 269 *tunnel_auth_response, |
264 http_proxy_socket->auth_controller())); | 270 http_proxy_socket->auth_controller())); |
265 } | 271 } |
266 return ERR_IO_PENDING; | 272 return ERR_IO_PENDING; |
267 | 273 |
268 case ERR_SSL_CLIENT_AUTH_CERT_NEEDED: | 274 case ERR_SSL_CLIENT_AUTH_CERT_NEEDED: |
269 MessageLoop::current()->PostTask( | 275 MessageLoop::current()->PostTask( |
270 FROM_HERE, | 276 FROM_HERE, |
271 method_factory_.NewRunnableMethod( | 277 method_factory_.NewRunnableMethod( |
272 &HttpStreamRequest::OnNeedsClientAuthCallback, | 278 &HttpStreamRequest::OnNeedsClientAuthCallback, |
273 connection_->ssl_error_response_info().cert_request_info)); | 279 connection_->ssl_error_response_info().cert_request_info)); |
274 return ERR_IO_PENDING; | 280 return ERR_IO_PENDING; |
275 | 281 |
| 282 case ERR_HTTPS_PROXY_TUNNEL_RESPONSE: { |
| 283 LOG(INFO) << "Creating stream"; |
| 284 scoped_ptr<ProxyClientSocket> proxy_socket( |
| 285 connection_->release_https_proxy_tunnel_response_socket()); |
| 286 MessageLoop::current()->PostTask( |
| 287 FROM_HERE, |
| 288 method_factory_.NewRunnableMethod( |
| 289 &HttpStreamRequest::OnHttpsProxyTunnelResponseCallback, |
| 290 connection_->ssl_error_response_info(), |
| 291 proxy_socket->CreateConnectResponseStream())); |
| 292 return ERR_IO_PENDING; |
| 293 } |
| 294 |
276 case OK: | 295 case OK: |
277 next_state_ = STATE_DONE; | 296 next_state_ = STATE_DONE; |
278 MessageLoop::current()->PostTask( | 297 MessageLoop::current()->PostTask( |
279 FROM_HERE, | 298 FROM_HERE, |
280 method_factory_.NewRunnableMethod( | 299 method_factory_.NewRunnableMethod( |
281 &HttpStreamRequest::OnStreamReadyCallback)); | 300 &HttpStreamRequest::OnStreamReadyCallback)); |
282 return ERR_IO_PENDING; | 301 return ERR_IO_PENDING; |
283 | 302 |
284 default: | 303 default: |
285 MessageLoop::current()->PostTask( | 304 MessageLoop::current()->PostTask( |
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
737 // this socket. Is there a race for two SPDY requests? We really | 756 // this socket. Is there a race for two SPDY requests? We really |
738 // need to plumb this through to the connect level. | 757 // need to plumb this through to the connect level. |
739 if (connection_->socket() && !connection_->is_reused()) | 758 if (connection_->socket() && !connection_->is_reused()) |
740 SetSocketMotivation(); | 759 SetSocketMotivation(); |
741 | 760 |
742 const ProxyServer& proxy_server = proxy_info()->proxy_server(); | 761 const ProxyServer& proxy_server = proxy_info()->proxy_server(); |
743 | 762 |
744 if (!using_spdy_) { | 763 if (!using_spdy_) { |
745 bool using_proxy = (proxy_info()->is_http() || proxy_info()->is_https()) && | 764 bool using_proxy = (proxy_info()->is_http() || proxy_info()->is_https()) && |
746 request_info().url.SchemeIs("http"); | 765 request_info().url.SchemeIs("http"); |
747 stream_.reset(new HttpBasicStream(connection_.release(), using_proxy)); | 766 stream_.reset(new HttpBasicStream(connection_.release(), NULL, |
| 767 using_proxy)); |
748 return OK; | 768 return OK; |
749 } | 769 } |
750 | 770 |
751 CHECK(!stream_.get()); | 771 CHECK(!stream_.get()); |
752 | 772 |
753 bool direct = true; | 773 bool direct = true; |
754 SpdySessionPool* spdy_pool = session_->spdy_session_pool(); | 774 SpdySessionPool* spdy_pool = session_->spdy_session_pool(); |
755 scoped_refptr<SpdySession> spdy_session; | 775 scoped_refptr<SpdySession> spdy_session; |
756 | 776 |
757 HostPortProxyPair pair(endpoint_, proxy_server); | 777 HostPortProxyPair pair(endpoint_, proxy_server); |
(...skipping 27 matching lines...) Expand all Loading... |
785 int error = spdy_pool->GetSpdySessionFromSocket( | 805 int error = spdy_pool->GetSpdySessionFromSocket( |
786 pair, session_->mutable_spdy_settings(), connection_.release(), | 806 pair, session_->mutable_spdy_settings(), connection_.release(), |
787 net_log_, spdy_certificate_error_, &spdy_session, using_ssl_); | 807 net_log_, spdy_certificate_error_, &spdy_session, using_ssl_); |
788 if (error != OK) | 808 if (error != OK) |
789 return error; | 809 return error; |
790 } | 810 } |
791 | 811 |
792 if (spdy_session->IsClosed()) | 812 if (spdy_session->IsClosed()) |
793 return ERR_CONNECTION_CLOSED; | 813 return ERR_CONNECTION_CLOSED; |
794 | 814 |
795 bool useRelativeUrl = direct || request_info().url.SchemeIs("https"); | 815 bool use_relative_url = direct || request_info().url.SchemeIs("https"); |
796 stream_.reset(new SpdyHttpStream(spdy_session, useRelativeUrl)); | 816 stream_.reset(new SpdyHttpStream(spdy_session, use_relative_url)); |
797 return OK; | 817 return OK; |
798 } | 818 } |
799 | 819 |
800 int HttpStreamRequest::DoCreateStreamComplete(int result) { | 820 int HttpStreamRequest::DoCreateStreamComplete(int result) { |
801 if (result < 0) | 821 if (result < 0) |
802 return result; | 822 return result; |
803 | 823 |
804 next_state_ = STATE_NONE; | 824 next_state_ = STATE_NONE; |
805 return OK; | 825 return OK; |
806 } | 826 } |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1057 base::TimeDelta::FromMinutes(6), | 1077 base::TimeDelta::FromMinutes(6), |
1058 100); | 1078 100); |
1059 break; | 1079 break; |
1060 default: | 1080 default: |
1061 NOTREACHED(); | 1081 NOTREACHED(); |
1062 break; | 1082 break; |
1063 } | 1083 } |
1064 } | 1084 } |
1065 | 1085 |
1066 } // namespace net | 1086 } // namespace net |
OLD | NEW |