OLD | NEW |
---|---|
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_job.h" | 5 #include "net/http/http_stream_factory_impl_job.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
141 // stream. | 141 // stream. |
142 std::unique_ptr<base::Value> NetLogHttpStreamProtoCallback( | 142 std::unique_ptr<base::Value> NetLogHttpStreamProtoCallback( |
143 NextProto negotiated_protocol, | 143 NextProto negotiated_protocol, |
144 NetLogCaptureMode /* capture_mode */) { | 144 NetLogCaptureMode /* capture_mode */) { |
145 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); | 145 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
146 | 146 |
147 dict->SetString("proto", NextProtoToString(negotiated_protocol)); | 147 dict->SetString("proto", NextProtoToString(negotiated_protocol)); |
148 return std::move(dict); | 148 return std::move(dict); |
149 } | 149 } |
150 | 150 |
151 // Returns parameters associated with the proxy resolution. | |
152 std::unique_ptr<base::Value> NetLogHttpStreamJobProxyServerResolved( | |
tbansal1
2017/05/09 20:38:48
Is it possible to keep this here? This adds the pr
xunjieli
2017/05/10 00:26:23
I moved this to http_stream_factory_impl_job_contr
| |
153 const ProxyServer& proxy_server, | |
154 NetLogCaptureMode /* capture_mode */) { | |
155 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); | |
156 | |
157 dict->SetString("proxy_server", proxy_server.is_valid() | |
158 ? proxy_server.ToPacString() | |
159 : std::string()); | |
160 return std::move(dict); | |
161 } | |
162 | |
163 HttpStreamFactoryImpl::Job::Job(Delegate* delegate, | 151 HttpStreamFactoryImpl::Job::Job(Delegate* delegate, |
164 JobType job_type, | 152 JobType job_type, |
165 HttpNetworkSession* session, | 153 HttpNetworkSession* session, |
166 const HttpRequestInfo& request_info, | 154 const HttpRequestInfo& request_info, |
167 RequestPriority priority, | 155 RequestPriority priority, |
156 ProxyInfo proxy_info, | |
168 const SSLConfig& server_ssl_config, | 157 const SSLConfig& server_ssl_config, |
169 const SSLConfig& proxy_ssl_config, | 158 const SSLConfig& proxy_ssl_config, |
170 HostPortPair destination, | 159 HostPortPair destination, |
171 GURL origin_url, | 160 GURL origin_url, |
172 bool enable_ip_based_pooling, | 161 bool enable_ip_based_pooling, |
173 NetLog* net_log) | 162 NetLog* net_log) |
174 : Job(delegate, | 163 : Job(delegate, |
175 job_type, | 164 job_type, |
176 session, | 165 session, |
177 request_info, | 166 request_info, |
178 priority, | 167 priority, |
168 proxy_info, | |
179 server_ssl_config, | 169 server_ssl_config, |
180 proxy_ssl_config, | 170 proxy_ssl_config, |
181 destination, | 171 destination, |
182 origin_url, | 172 origin_url, |
183 AlternativeService(), | 173 AlternativeService(), |
184 ProxyServer(), | 174 ProxyServer(), |
185 enable_ip_based_pooling, | 175 enable_ip_based_pooling, |
186 net_log) {} | 176 net_log) {} |
187 | 177 |
188 HttpStreamFactoryImpl::Job::Job(Delegate* delegate, | 178 HttpStreamFactoryImpl::Job::Job(Delegate* delegate, |
189 JobType job_type, | 179 JobType job_type, |
190 HttpNetworkSession* session, | 180 HttpNetworkSession* session, |
191 const HttpRequestInfo& request_info, | 181 const HttpRequestInfo& request_info, |
192 RequestPriority priority, | 182 RequestPriority priority, |
183 ProxyInfo proxy_info, | |
193 const SSLConfig& server_ssl_config, | 184 const SSLConfig& server_ssl_config, |
194 const SSLConfig& proxy_ssl_config, | 185 const SSLConfig& proxy_ssl_config, |
195 HostPortPair destination, | 186 HostPortPair destination, |
196 GURL origin_url, | 187 GURL origin_url, |
197 AlternativeService alternative_service, | 188 AlternativeService alternative_service, |
198 const ProxyServer& alternative_proxy_server, | 189 const ProxyServer& alternative_proxy_server, |
199 bool enable_ip_based_pooling, | 190 bool enable_ip_based_pooling, |
200 NetLog* net_log) | 191 NetLog* net_log) |
201 : request_info_(request_info), | 192 : request_info_(request_info), |
202 priority_(priority), | 193 priority_(priority), |
194 proxy_info_(proxy_info), | |
203 server_ssl_config_(server_ssl_config), | 195 server_ssl_config_(server_ssl_config), |
204 proxy_ssl_config_(proxy_ssl_config), | 196 proxy_ssl_config_(proxy_ssl_config), |
205 net_log_( | 197 net_log_( |
206 NetLogWithSource::Make(net_log, NetLogSourceType::HTTP_STREAM_JOB)), | 198 NetLogWithSource::Make(net_log, NetLogSourceType::HTTP_STREAM_JOB)), |
207 io_callback_(base::Bind(&Job::OnIOComplete, base::Unretained(this))), | 199 io_callback_(base::Bind(&Job::OnIOComplete, base::Unretained(this))), |
208 connection_(new ClientSocketHandle), | 200 connection_(new ClientSocketHandle), |
209 session_(session), | 201 session_(session), |
210 state_(STATE_NONE), | 202 state_(STATE_NONE), |
211 next_state_(STATE_NONE), | 203 next_state_(STATE_NONE), |
212 pac_request_(NULL), | |
213 destination_(destination), | 204 destination_(destination), |
214 origin_url_(origin_url), | 205 origin_url_(origin_url), |
215 alternative_service_(alternative_service), | 206 alternative_service_(alternative_service), |
216 alternative_proxy_server_(alternative_proxy_server), | 207 alternative_proxy_server_(alternative_proxy_server), |
217 enable_ip_based_pooling_(enable_ip_based_pooling), | 208 enable_ip_based_pooling_(enable_ip_based_pooling), |
218 delegate_(delegate), | 209 delegate_(delegate), |
219 job_type_(job_type), | 210 job_type_(job_type), |
220 using_ssl_(origin_url_.SchemeIs(url::kHttpsScheme) || | 211 using_ssl_(origin_url_.SchemeIs(url::kHttpsScheme) || |
221 origin_url_.SchemeIs(url::kWssScheme)), | 212 origin_url_.SchemeIs(url::kWssScheme)), |
222 using_spdy_(false), | 213 using_spdy_(false), |
223 using_quic_(false), | 214 using_quic_(false), |
215 reconsider_proxy_(false), | |
224 quic_request_(session_->quic_stream_factory(), | 216 quic_request_(session_->quic_stream_factory(), |
225 session_->http_server_properties()), | 217 session_->http_server_properties()), |
226 using_existing_quic_session_(false), | 218 using_existing_quic_session_(false), |
227 establishing_tunnel_(false), | 219 establishing_tunnel_(false), |
228 was_alpn_negotiated_(false), | 220 was_alpn_negotiated_(false), |
229 negotiated_protocol_(kProtoUnknown), | 221 negotiated_protocol_(kProtoUnknown), |
230 num_streams_(0), | 222 num_streams_(0), |
231 spdy_session_direct_(false), | 223 spdy_session_direct_(false), |
232 stream_type_(HttpStreamRequest::BIDIRECTIONAL_STREAM), | 224 stream_type_(HttpStreamRequest::BIDIRECTIONAL_STREAM), |
233 ptr_factory_(this) { | 225 ptr_factory_(this) { |
(...skipping 29 matching lines...) Expand all Loading... | |
263 net_log_.EndEvent(NetLogEventType::HTTP_STREAM_JOB); | 255 net_log_.EndEvent(NetLogEventType::HTTP_STREAM_JOB); |
264 | 256 |
265 // When we're in a partially constructed state, waiting for the user to | 257 // When we're in a partially constructed state, waiting for the user to |
266 // provide certificate handling information or authentication, we can't reuse | 258 // provide certificate handling information or authentication, we can't reuse |
267 // this stream at all. | 259 // this stream at all. |
268 if (next_state_ == STATE_WAITING_USER_ACTION) { | 260 if (next_state_ == STATE_WAITING_USER_ACTION) { |
269 connection_->socket()->Disconnect(); | 261 connection_->socket()->Disconnect(); |
270 connection_.reset(); | 262 connection_.reset(); |
271 } | 263 } |
272 | 264 |
273 if (pac_request_) | |
274 session_->proxy_service()->CancelPacRequest(pac_request_); | |
275 | |
276 // The stream could be in a partial state. It is not reusable. | 265 // The stream could be in a partial state. It is not reusable. |
277 if (stream_.get() && next_state_ != STATE_DONE) | 266 if (stream_.get() && next_state_ != STATE_DONE) |
278 stream_->Close(true /* not reusable */); | 267 stream_->Close(true /* not reusable */); |
279 } | 268 } |
280 | 269 |
281 void HttpStreamFactoryImpl::Job::Start( | 270 void HttpStreamFactoryImpl::Job::Start( |
282 HttpStreamRequest::StreamType stream_type) { | 271 HttpStreamRequest::StreamType stream_type) { |
283 stream_type_ = stream_type; | 272 stream_type_ = stream_type; |
284 StartInternal(); | 273 StartInternal(); |
285 } | 274 } |
(...skipping 24 matching lines...) Expand all Loading... | |
310 int HttpStreamFactoryImpl::Job::RestartTunnelWithProxyAuth() { | 299 int HttpStreamFactoryImpl::Job::RestartTunnelWithProxyAuth() { |
311 DCHECK(establishing_tunnel_); | 300 DCHECK(establishing_tunnel_); |
312 next_state_ = STATE_RESTART_TUNNEL_AUTH; | 301 next_state_ = STATE_RESTART_TUNNEL_AUTH; |
313 stream_.reset(); | 302 stream_.reset(); |
314 RunLoop(OK); | 303 RunLoop(OK); |
315 return ERR_IO_PENDING; | 304 return ERR_IO_PENDING; |
316 } | 305 } |
317 | 306 |
318 LoadState HttpStreamFactoryImpl::Job::GetLoadState() const { | 307 LoadState HttpStreamFactoryImpl::Job::GetLoadState() const { |
319 switch (next_state_) { | 308 switch (next_state_) { |
320 case STATE_RESOLVE_PROXY_COMPLETE: | |
321 return session_->proxy_service()->GetLoadState(pac_request_); | |
322 case STATE_INIT_CONNECTION_COMPLETE: | 309 case STATE_INIT_CONNECTION_COMPLETE: |
323 case STATE_CREATE_STREAM_COMPLETE: | 310 case STATE_CREATE_STREAM_COMPLETE: |
324 return using_quic_ ? LOAD_STATE_CONNECTING : connection_->GetLoadState(); | 311 return using_quic_ ? LOAD_STATE_CONNECTING : connection_->GetLoadState(); |
325 default: | 312 default: |
326 return LOAD_STATE_IDLE; | 313 return LOAD_STATE_IDLE; |
327 } | 314 } |
328 } | 315 } |
329 | 316 |
330 void HttpStreamFactoryImpl::Job::Resume() { | 317 void HttpStreamFactoryImpl::Job::Resume() { |
331 DCHECK_EQ(job_type_, MAIN); | 318 DCHECK_EQ(job_type_, MAIN); |
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
680 do { | 667 do { |
681 State state = next_state_; | 668 State state = next_state_; |
682 // Added to investigate crbug.com/711721. | 669 // Added to investigate crbug.com/711721. |
683 state_ = state; | 670 state_ = state; |
684 next_state_ = STATE_NONE; | 671 next_state_ = STATE_NONE; |
685 switch (state) { | 672 switch (state) { |
686 case STATE_START: | 673 case STATE_START: |
687 DCHECK_EQ(OK, rv); | 674 DCHECK_EQ(OK, rv); |
688 rv = DoStart(); | 675 rv = DoStart(); |
689 break; | 676 break; |
690 case STATE_RESOLVE_PROXY: | |
691 DCHECK_EQ(OK, rv); | |
692 rv = DoResolveProxy(); | |
693 break; | |
694 case STATE_RESOLVE_PROXY_COMPLETE: | |
695 rv = DoResolveProxyComplete(rv); | |
696 break; | |
697 case STATE_WAIT: | 677 case STATE_WAIT: |
698 DCHECK_EQ(OK, rv); | 678 DCHECK_EQ(OK, rv); |
699 rv = DoWait(); | 679 rv = DoWait(); |
700 break; | 680 break; |
701 case STATE_WAIT_COMPLETE: | 681 case STATE_WAIT_COMPLETE: |
702 rv = DoWaitComplete(rv); | 682 rv = DoWaitComplete(rv); |
703 break; | 683 break; |
704 case STATE_INIT_CONNECTION: | 684 case STATE_INIT_CONNECTION: |
705 DCHECK_EQ(OK, rv); | 685 DCHECK_EQ(OK, rv); |
706 rv = DoInitConnection(); | 686 rv = DoInitConnection(); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
753 net_log->AddEvent(NetLogEventType::HTTP_STREAM_REQUEST_STARTED_JOB, | 733 net_log->AddEvent(NetLogEventType::HTTP_STREAM_REQUEST_STARTED_JOB, |
754 net_log_.source().ToEventParametersCallback()); | 734 net_log_.source().ToEventParametersCallback()); |
755 } | 735 } |
756 | 736 |
757 // Don't connect to restricted ports. | 737 // Don't connect to restricted ports. |
758 if (!IsPortAllowedForScheme(destination_.port(), | 738 if (!IsPortAllowedForScheme(destination_.port(), |
759 request_info_.url.scheme())) { | 739 request_info_.url.scheme())) { |
760 return ERR_UNSAFE_PORT; | 740 return ERR_UNSAFE_PORT; |
761 } | 741 } |
762 | 742 |
763 next_state_ = STATE_RESOLVE_PROXY; | 743 next_state_ = STATE_WAIT; |
764 return OK; | 744 return OK; |
765 } | 745 } |
766 | 746 |
767 int HttpStreamFactoryImpl::Job::DoResolveProxy() { | |
768 DCHECK(!pac_request_); | |
769 DCHECK(session_); | |
770 | |
771 next_state_ = STATE_RESOLVE_PROXY_COMPLETE; | |
772 | |
773 if (request_info_.load_flags & LOAD_BYPASS_PROXY) { | |
774 proxy_info_.UseDirect(); | |
775 return OK; | |
776 } | |
777 | |
778 // If an alternative proxy server was provided, use that. | |
779 if (alternative_proxy_server_.is_valid()) { | |
780 proxy_info_.UseProxyServer(alternative_proxy_server_); | |
781 return OK; | |
782 } | |
783 | |
784 return session_->proxy_service()->ResolveProxy( | |
785 origin_url_, request_info_.method, &proxy_info_, io_callback_, | |
786 &pac_request_, session_->params().proxy_delegate, net_log_); | |
787 } | |
788 | |
789 int HttpStreamFactoryImpl::Job::DoResolveProxyComplete(int result) { | |
790 pac_request_ = NULL; | |
791 | |
792 net_log_.AddEvent( | |
793 NetLogEventType::HTTP_STREAM_JOB_PROXY_SERVER_RESOLVED, | |
794 base::Bind( | |
795 &NetLogHttpStreamJobProxyServerResolved, | |
796 proxy_info_.is_empty() ? ProxyServer() : proxy_info_.proxy_server())); | |
797 | |
798 if (result == OK) { | |
799 // Remove unsupported proxies from the list. | |
800 int supported_proxies = | |
801 ProxyServer::SCHEME_DIRECT | ProxyServer::SCHEME_HTTP | | |
802 ProxyServer::SCHEME_HTTPS | ProxyServer::SCHEME_SOCKS4 | | |
803 ProxyServer::SCHEME_SOCKS5; | |
804 | |
805 if (session_->IsQuicEnabled()) | |
806 supported_proxies |= ProxyServer::SCHEME_QUIC; | |
807 | |
808 proxy_info_.RemoveProxiesWithoutScheme(supported_proxies); | |
809 | |
810 if (proxy_info_.is_empty()) { | |
811 // No proxies/direct to choose from. This happens when we don't support | |
812 // any of the proxies in the returned list. | |
813 result = ERR_NO_SUPPORTED_PROXIES; | |
814 } else if (using_quic_ && | |
815 (!proxy_info_.is_quic() && !proxy_info_.is_direct())) { | |
816 // QUIC can not be spoken to non-QUIC proxies. This error should not be | |
817 // user visible, because the non-alternative Job should be resumed. | |
818 result = ERR_NO_SUPPORTED_PROXIES; | |
819 } | |
820 } | |
821 | |
822 if (result != OK) { | |
823 return result; | |
824 } | |
825 | |
826 next_state_ = STATE_WAIT; | |
827 | |
828 delegate_->OnResolveProxyComplete(this, request_info_, priority_, | |
829 server_ssl_config_, proxy_ssl_config_, | |
830 stream_type_); | |
831 | |
832 return OK; | |
833 } | |
834 | |
835 bool HttpStreamFactoryImpl::Job::ShouldForceQuic() const { | 747 bool HttpStreamFactoryImpl::Job::ShouldForceQuic() const { |
836 return session_->IsQuicEnabled() && | 748 return session_->IsQuicEnabled() && |
837 (base::ContainsKey(session_->params().origins_to_force_quic_on, | 749 (base::ContainsKey(session_->params().origins_to_force_quic_on, |
838 HostPortPair()) || | 750 HostPortPair()) || |
839 base::ContainsKey(session_->params().origins_to_force_quic_on, | 751 base::ContainsKey(session_->params().origins_to_force_quic_on, |
840 destination_)) && | 752 destination_)) && |
841 proxy_info_.is_direct() && origin_url_.SchemeIs(url::kHttpsScheme); | 753 proxy_info_.is_direct() && origin_url_.SchemeIs(url::kHttpsScheme); |
842 } | 754 } |
843 | 755 |
844 int HttpStreamFactoryImpl::Job::DoWait() { | 756 int HttpStreamFactoryImpl::Job::DoWait() { |
(...skipping 22 matching lines...) Expand all Loading... | |
867 | 779 |
868 return result; | 780 return result; |
869 } | 781 } |
870 | 782 |
871 int HttpStreamFactoryImpl::Job::DoInitConnectionImpl() { | 783 int HttpStreamFactoryImpl::Job::DoInitConnectionImpl() { |
872 // TODO(pkasting): Remove ScopedTracker below once crbug.com/462812 is fixed. | 784 // TODO(pkasting): Remove ScopedTracker below once crbug.com/462812 is fixed. |
873 tracked_objects::ScopedTracker tracking_profile( | 785 tracked_objects::ScopedTracker tracking_profile( |
874 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 786 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
875 "462812 HttpStreamFactoryImpl::Job::DoInitConnection")); | 787 "462812 HttpStreamFactoryImpl::Job::DoInitConnection")); |
876 DCHECK(!connection_->is_initialized()); | 788 DCHECK(!connection_->is_initialized()); |
789 | |
790 if (proxy_info_.is_empty()) { | |
791 // No proxies/direct to choose from. This happens when we don't support | |
792 // any of the proxies in the returned list. | |
793 return ERR_NO_SUPPORTED_PROXIES; | |
794 } else if (using_quic_ && | |
Ryan Hamilton
2017/05/09 19:22:06
nit: no else after return.
xunjieli
2017/05/10 00:26:23
Done.
| |
795 (!proxy_info_.is_quic() && !proxy_info_.is_direct())) { | |
796 // QUIC can not be spoken to non-QUIC proxies. This error should not be | |
797 // user visible, because the non-alternative Job should be resumed. | |
798 return ERR_NO_SUPPORTED_PROXIES; | |
799 } | |
800 | |
877 DCHECK(proxy_info_.proxy_server().is_valid()); | 801 DCHECK(proxy_info_.proxy_server().is_valid()); |
878 next_state_ = STATE_INIT_CONNECTION_COMPLETE; | 802 next_state_ = STATE_INIT_CONNECTION_COMPLETE; |
879 | 803 |
880 if (delegate_->OnInitConnection(proxy_info_)) { | 804 if (delegate_->OnInitConnection(proxy_info_)) { |
881 // Return since the connection initialization can be skipped. | 805 // Return since the connection initialization can be skipped. |
882 return OK; | 806 return OK; |
883 } | 807 } |
884 | 808 |
885 using_spdy_ = false; | 809 using_spdy_ = false; |
886 | 810 |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1139 // Quic session is closed before stream can be created. | 1063 // Quic session is closed before stream can be created. |
1140 return ERR_CONNECTION_CLOSED; | 1064 return ERR_CONNECTION_CLOSED; |
1141 } | 1065 } |
1142 } | 1066 } |
1143 next_state_ = STATE_NONE; | 1067 next_state_ = STATE_NONE; |
1144 return OK; | 1068 return OK; |
1145 } | 1069 } |
1146 | 1070 |
1147 if (result < 0 && !ssl_started) | 1071 if (result < 0 && !ssl_started) |
1148 return ReconsiderProxyAfterError(result); | 1072 return ReconsiderProxyAfterError(result); |
1073 | |
1149 establishing_tunnel_ = false; | 1074 establishing_tunnel_ = false; |
1150 | 1075 |
1151 // Handle SSL errors below. | 1076 // Handle SSL errors below. |
1152 if (using_ssl_) { | 1077 if (using_ssl_) { |
1153 DCHECK(ssl_started); | 1078 DCHECK(ssl_started); |
1154 if (IsCertificateError(result)) { | 1079 if (IsCertificateError(result)) { |
1155 result = HandleCertificateError(result); | 1080 result = HandleCertificateError(result); |
1156 if (result == OK && !connection_->socket()->IsConnectedAndIdle()) { | 1081 if (result == OK && !connection_->socket()->IsConnectedAndIdle()) { |
1157 ReturnToStateInitConnection(true /* close connection */); | 1082 ReturnToStateInitConnection(true /* close connection */); |
1158 return result; | 1083 return result; |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1405 } | 1330 } |
1406 | 1331 |
1407 if (request_info_.load_flags & LOAD_VERIFY_EV_CERT) | 1332 if (request_info_.load_flags & LOAD_VERIFY_EV_CERT) |
1408 ssl_config->verify_ev_cert = true; | 1333 ssl_config->verify_ev_cert = true; |
1409 | 1334 |
1410 // Disable Channel ID if privacy mode is enabled. | 1335 // Disable Channel ID if privacy mode is enabled. |
1411 if (request_info_.privacy_mode == PRIVACY_MODE_ENABLED) | 1336 if (request_info_.privacy_mode == PRIVACY_MODE_ENABLED) |
1412 ssl_config->channel_id_enabled = false; | 1337 ssl_config->channel_id_enabled = false; |
1413 } | 1338 } |
1414 | 1339 |
1415 | |
1416 int HttpStreamFactoryImpl::Job::ReconsiderProxyAfterError(int error) { | 1340 int HttpStreamFactoryImpl::Job::ReconsiderProxyAfterError(int error) { |
1417 DCHECK(!pac_request_); | |
1418 DCHECK(session_); | |
1419 | |
1420 // A failure to resolve the hostname or any error related to establishing a | |
1421 // TCP connection could be grounds for trying a new proxy configuration. | |
1422 // | |
1423 // Why do this when a hostname cannot be resolved? Some URLs only make sense | |
1424 // to proxy servers. The hostname in those URLs might fail to resolve if we | |
1425 // are still using a non-proxy config. We need to check if a proxy config | |
1426 // now exists that corresponds to a proxy server that could load the URL. | |
1427 // | |
1428 switch (error) { | 1341 switch (error) { |
1429 case ERR_PROXY_CONNECTION_FAILED: | 1342 case ERR_PROXY_CONNECTION_FAILED: |
1430 case ERR_NAME_NOT_RESOLVED: | 1343 case ERR_NAME_NOT_RESOLVED: |
1431 case ERR_INTERNET_DISCONNECTED: | 1344 case ERR_INTERNET_DISCONNECTED: |
1432 case ERR_ADDRESS_UNREACHABLE: | 1345 case ERR_ADDRESS_UNREACHABLE: |
1433 case ERR_CONNECTION_CLOSED: | 1346 case ERR_CONNECTION_CLOSED: |
1434 case ERR_CONNECTION_TIMED_OUT: | 1347 case ERR_CONNECTION_TIMED_OUT: |
1435 case ERR_CONNECTION_RESET: | 1348 case ERR_CONNECTION_RESET: |
1436 case ERR_CONNECTION_REFUSED: | 1349 case ERR_CONNECTION_REFUSED: |
1437 case ERR_CONNECTION_ABORTED: | 1350 case ERR_CONNECTION_ABORTED: |
(...skipping 18 matching lines...) Expand all Loading... | |
1456 // | 1369 // |
1457 // Note that if the host resolving was done by the SOCKS5 proxy, we can't | 1370 // Note that if the host resolving was done by the SOCKS5 proxy, we can't |
1458 // differentiate between a proxy-side "host not found" versus a proxy-side | 1371 // differentiate between a proxy-side "host not found" versus a proxy-side |
1459 // "address unreachable" error, and will report both of these failures as | 1372 // "address unreachable" error, and will report both of these failures as |
1460 // ERR_ADDRESS_UNREACHABLE. | 1373 // ERR_ADDRESS_UNREACHABLE. |
1461 return ERR_ADDRESS_UNREACHABLE; | 1374 return ERR_ADDRESS_UNREACHABLE; |
1462 default: | 1375 default: |
1463 return error; | 1376 return error; |
1464 } | 1377 } |
1465 | 1378 |
1466 // Do not bypass non-QUIC proxy on ERR_MSG_TOO_BIG. | |
1467 if (!proxy_info_.is_quic() && error == ERR_MSG_TOO_BIG) | |
1468 return error; | |
1469 | |
1470 if (request_info_.load_flags & LOAD_BYPASS_PROXY) | |
1471 return error; | |
1472 | |
1473 // Alternative proxy server job should not use fallback proxies, and instead | 1379 // Alternative proxy server job should not use fallback proxies, and instead |
1474 // return. This would resume the main job (if possible) which may try the | 1380 // return. This would resume the main job (if possible) which may try the |
1475 // fallback proxies. | 1381 // fallback proxies. |
1476 if (alternative_proxy_server_.is_valid()) { | 1382 if (job_type() == ALTERNATIVE && alternative_proxy_server().is_valid()) { |
tbansal1
2017/05/09 20:38:48
why is the check for job_type needed?
xunjieli
2017/05/10 00:26:23
Done. Removed.
| |
1477 DCHECK_EQ(STATE_NONE, next_state_); | 1383 DCHECK_EQ(STATE_NONE, next_state_); |
1478 return error; | 1384 return error; |
1479 } | 1385 } |
1480 | 1386 |
1481 if (proxy_info_.is_https() && proxy_ssl_config_.send_client_cert) { | 1387 reconsider_proxy_ = true; |
1482 session_->ssl_client_auth_cache()->Remove( | 1388 return error; |
1483 proxy_info_.proxy_server().host_port_pair()); | |
1484 } | |
1485 | |
1486 int rv = session_->proxy_service()->ReconsiderProxyAfterError( | |
1487 request_info_.url, request_info_.method, error, &proxy_info_, | |
1488 io_callback_, &pac_request_, session_->params().proxy_delegate, net_log_); | |
1489 if (rv == OK || rv == ERR_IO_PENDING) { | |
1490 // If the error was during connection setup, there is no socket to | |
1491 // disconnect. | |
1492 if (connection_->socket()) | |
1493 connection_->socket()->Disconnect(); | |
1494 connection_->Reset(); | |
1495 delegate_->RemoveRequestFromSpdySessionRequestMapForJob(this); | |
1496 next_state_ = STATE_RESOLVE_PROXY_COMPLETE; | |
1497 } else { | |
1498 // If ReconsiderProxyAfterError() failed synchronously, it means | |
1499 // there was nothing left to fall-back to, so fail the transaction | |
1500 // with the last connection error we got. | |
1501 // TODO(eroman): This is a confusing contract, make it more obvious. | |
1502 rv = error; | |
1503 } | |
1504 | |
1505 return rv; | |
1506 } | 1389 } |
1507 | 1390 |
1508 int HttpStreamFactoryImpl::Job::HandleCertificateError(int error) { | 1391 int HttpStreamFactoryImpl::Job::HandleCertificateError(int error) { |
1509 DCHECK(using_ssl_); | 1392 DCHECK(using_ssl_); |
1510 DCHECK(IsCertificateError(error)); | 1393 DCHECK(IsCertificateError(error)); |
1511 | 1394 |
1512 SSLClientSocket* ssl_socket = | 1395 SSLClientSocket* ssl_socket = |
1513 static_cast<SSLClientSocket*>(connection_->socket()); | 1396 static_cast<SSLClientSocket*>(connection_->socket()); |
1514 ssl_socket->GetSSLInfo(&ssl_info_); | 1397 ssl_socket->GetSSLInfo(&ssl_info_); |
1515 | 1398 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1557 return; | 1440 return; |
1558 | 1441 |
1559 ConnectionAttempts socket_attempts = connection_->connection_attempts(); | 1442 ConnectionAttempts socket_attempts = connection_->connection_attempts(); |
1560 if (connection_->socket()) { | 1443 if (connection_->socket()) { |
1561 connection_->socket()->GetConnectionAttempts(&socket_attempts); | 1444 connection_->socket()->GetConnectionAttempts(&socket_attempts); |
1562 } | 1445 } |
1563 | 1446 |
1564 delegate_->AddConnectionAttemptsToRequest(this, socket_attempts); | 1447 delegate_->AddConnectionAttemptsToRequest(this, socket_attempts); |
1565 } | 1448 } |
1566 | 1449 |
1450 HttpStreamFactoryImpl::JobFactory::JobFactory() {} | |
1451 | |
1452 HttpStreamFactoryImpl::JobFactory::~JobFactory() {} | |
1453 | |
1454 HttpStreamFactoryImpl::Job* HttpStreamFactoryImpl::JobFactory::CreateJob( | |
1455 HttpStreamFactoryImpl::Job::Delegate* delegate, | |
1456 HttpStreamFactoryImpl::JobType job_type, | |
1457 HttpNetworkSession* session, | |
1458 const HttpRequestInfo& request_info, | |
1459 RequestPriority priority, | |
1460 ProxyInfo proxy_info, | |
1461 const SSLConfig& server_ssl_config, | |
1462 const SSLConfig& proxy_ssl_config, | |
1463 HostPortPair destination, | |
1464 GURL origin_url, | |
1465 bool enable_ip_based_pooling, | |
1466 NetLog* net_log) { | |
1467 return new HttpStreamFactoryImpl::Job( | |
1468 delegate, job_type, session, request_info, priority, proxy_info, | |
1469 server_ssl_config, proxy_ssl_config, destination, origin_url, | |
1470 enable_ip_based_pooling, net_log); | |
1471 } | |
1472 | |
1473 HttpStreamFactoryImpl::Job* HttpStreamFactoryImpl::JobFactory::CreateJob( | |
1474 HttpStreamFactoryImpl::Job::Delegate* delegate, | |
1475 HttpStreamFactoryImpl::JobType job_type, | |
1476 HttpNetworkSession* session, | |
1477 const HttpRequestInfo& request_info, | |
1478 RequestPriority priority, | |
1479 ProxyInfo proxy_info, | |
1480 const SSLConfig& server_ssl_config, | |
1481 const SSLConfig& proxy_ssl_config, | |
1482 HostPortPair destination, | |
1483 GURL origin_url, | |
1484 AlternativeService alternative_service, | |
1485 bool enable_ip_based_pooling, | |
1486 NetLog* net_log) { | |
1487 return new HttpStreamFactoryImpl::Job( | |
1488 delegate, job_type, session, request_info, priority, proxy_info, | |
1489 server_ssl_config, proxy_ssl_config, destination, origin_url, | |
1490 alternative_service, ProxyServer(), enable_ip_based_pooling, net_log); | |
1491 } | |
1492 | |
1493 HttpStreamFactoryImpl::Job* HttpStreamFactoryImpl::JobFactory::CreateJob( | |
1494 HttpStreamFactoryImpl::Job::Delegate* delegate, | |
1495 HttpStreamFactoryImpl::JobType job_type, | |
1496 HttpNetworkSession* session, | |
1497 const HttpRequestInfo& request_info, | |
1498 RequestPriority priority, | |
1499 ProxyInfo proxy_info, | |
1500 const SSLConfig& server_ssl_config, | |
1501 const SSLConfig& proxy_ssl_config, | |
1502 HostPortPair destination, | |
1503 GURL origin_url, | |
1504 const ProxyServer& alternative_proxy_server, | |
1505 bool enable_ip_based_pooling, | |
1506 NetLog* net_log) { | |
1507 return new HttpStreamFactoryImpl::Job( | |
1508 delegate, job_type, session, request_info, priority, proxy_info, | |
1509 server_ssl_config, proxy_ssl_config, destination, origin_url, | |
1510 AlternativeService(), alternative_proxy_server, enable_ip_based_pooling, | |
1511 net_log); | |
1512 } | |
1513 | |
1567 } // namespace net | 1514 } // namespace net |
OLD | NEW |