| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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_network_transaction.h" | 5 #include "net/http/http_network_transaction.h" |
| 6 | 6 |
| 7 #include "base/scoped_ptr.h" | 7 #include "base/scoped_ptr.h" |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/field_trial.h" | 9 #include "base/field_trial.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 if (rv == ERR_IO_PENDING) | 175 if (rv == ERR_IO_PENDING) |
| 176 user_callback_ = callback; | 176 user_callback_ = callback; |
| 177 return rv; | 177 return rv; |
| 178 } | 178 } |
| 179 | 179 |
| 180 int HttpNetworkTransaction::RestartIgnoringLastError( | 180 int HttpNetworkTransaction::RestartIgnoringLastError( |
| 181 CompletionCallback* callback) { | 181 CompletionCallback* callback) { |
| 182 if (connection_.socket()->IsConnected()) { | 182 if (connection_.socket()->IsConnected()) { |
| 183 next_state_ = STATE_WRITE_HEADERS; | 183 next_state_ = STATE_WRITE_HEADERS; |
| 184 } else { | 184 } else { |
| 185 connection_.socket()->Disconnect(); | 185 connection_.set_socket(NULL); |
| 186 connection_.Reset(); | 186 connection_.Reset(); |
| 187 next_state_ = STATE_INIT_CONNECTION; | 187 next_state_ = STATE_INIT_CONNECTION; |
| 188 } | 188 } |
| 189 int rv = DoLoop(OK); | 189 int rv = DoLoop(OK); |
| 190 if (rv == ERR_IO_PENDING) | 190 if (rv == ERR_IO_PENDING) |
| 191 user_callback_ = callback; | 191 user_callback_ = callback; |
| 192 return rv; | 192 return rv; |
| 193 } | 193 } |
| 194 | 194 |
| 195 int HttpNetworkTransaction::RestartWithAuth( | 195 int HttpNetworkTransaction::RestartWithAuth( |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 // the response body. | 299 // the response body. |
| 300 DidDrainBodyForAuthRestart(keep_alive); | 300 DidDrainBodyForAuthRestart(keep_alive); |
| 301 } | 301 } |
| 302 | 302 |
| 303 void HttpNetworkTransaction::DidDrainBodyForAuthRestart(bool keep_alive) { | 303 void HttpNetworkTransaction::DidDrainBodyForAuthRestart(bool keep_alive) { |
| 304 if (keep_alive) { | 304 if (keep_alive) { |
| 305 next_state_ = STATE_WRITE_HEADERS; | 305 next_state_ = STATE_WRITE_HEADERS; |
| 306 reused_socket_ = true; | 306 reused_socket_ = true; |
| 307 } else { | 307 } else { |
| 308 next_state_ = STATE_INIT_CONNECTION; | 308 next_state_ = STATE_INIT_CONNECTION; |
| 309 connection_.socket()->Disconnect(); | 309 connection_.set_socket(NULL); |
| 310 connection_.Reset(); | 310 connection_.Reset(); |
| 311 } | 311 } |
| 312 | 312 |
| 313 // Reset the other member variables. | 313 // Reset the other member variables. |
| 314 ResetStateForRestart(); | 314 ResetStateForRestart(); |
| 315 } | 315 } |
| 316 | 316 |
| 317 int HttpNetworkTransaction::Read(IOBuffer* buf, int buf_len, | 317 int HttpNetworkTransaction::Read(IOBuffer* buf, int buf_len, |
| 318 CompletionCallback* callback) { | 318 CompletionCallback* callback) { |
| 319 DCHECK(response_.headers); | 319 DCHECK(response_.headers); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 349 const HttpResponseInfo* HttpNetworkTransaction::GetResponseInfo() const { | 349 const HttpResponseInfo* HttpNetworkTransaction::GetResponseInfo() const { |
| 350 return (response_.headers || response_.ssl_info.cert) ? &response_ : NULL; | 350 return (response_.headers || response_.ssl_info.cert) ? &response_ : NULL; |
| 351 } | 351 } |
| 352 | 352 |
| 353 LoadState HttpNetworkTransaction::GetLoadState() const { | 353 LoadState HttpNetworkTransaction::GetLoadState() const { |
| 354 // TODO(wtc): Define a new LoadState value for the | 354 // TODO(wtc): Define a new LoadState value for the |
| 355 // STATE_INIT_CONNECTION_COMPLETE state, which delays the HTTP request. | 355 // STATE_INIT_CONNECTION_COMPLETE state, which delays the HTTP request. |
| 356 switch (next_state_) { | 356 switch (next_state_) { |
| 357 case STATE_RESOLVE_PROXY_COMPLETE: | 357 case STATE_RESOLVE_PROXY_COMPLETE: |
| 358 return LOAD_STATE_RESOLVING_PROXY_FOR_URL; | 358 return LOAD_STATE_RESOLVING_PROXY_FOR_URL; |
| 359 case STATE_INIT_CONNECTION_COMPLETE: | 359 case STATE_RESOLVE_HOST_COMPLETE: |
| 360 return connection_.GetLoadState(); | 360 return LOAD_STATE_RESOLVING_HOST; |
| 361 case STATE_TCP_CONNECT_COMPLETE: |
| 362 return LOAD_STATE_CONNECTING; |
| 361 case STATE_WRITE_HEADERS_COMPLETE: | 363 case STATE_WRITE_HEADERS_COMPLETE: |
| 362 case STATE_WRITE_BODY_COMPLETE: | 364 case STATE_WRITE_BODY_COMPLETE: |
| 363 return LOAD_STATE_SENDING_REQUEST; | 365 return LOAD_STATE_SENDING_REQUEST; |
| 364 case STATE_READ_HEADERS_COMPLETE: | 366 case STATE_READ_HEADERS_COMPLETE: |
| 365 return LOAD_STATE_WAITING_FOR_RESPONSE; | 367 return LOAD_STATE_WAITING_FOR_RESPONSE; |
| 366 case STATE_READ_BODY_COMPLETE: | 368 case STATE_READ_BODY_COMPLETE: |
| 367 return LOAD_STATE_READING_RESPONSE; | 369 return LOAD_STATE_READING_RESPONSE; |
| 368 default: | 370 default: |
| 369 return LOAD_STATE_IDLE; | 371 return LOAD_STATE_IDLE; |
| 370 } | 372 } |
| 371 } | 373 } |
| 372 | 374 |
| 373 uint64 HttpNetworkTransaction::GetUploadProgress() const { | 375 uint64 HttpNetworkTransaction::GetUploadProgress() const { |
| 374 if (!request_body_stream_.get()) | 376 if (!request_body_stream_.get()) |
| 375 return 0; | 377 return 0; |
| 376 | 378 |
| 377 return request_body_stream_->position(); | 379 return request_body_stream_->position(); |
| 378 } | 380 } |
| 379 | 381 |
| 380 HttpNetworkTransaction::~HttpNetworkTransaction() { | 382 HttpNetworkTransaction::~HttpNetworkTransaction() { |
| 381 // If we still have an open socket, then make sure to disconnect it so we | 383 // If we still have an open socket, then make sure to close it so we don't |
| 382 // don't try to reuse it later on. | 384 // try to reuse it later on. |
| 383 if (connection_.is_initialized()) | 385 if (connection_.is_initialized()) |
| 384 connection_.socket()->Disconnect(); | 386 connection_.set_socket(NULL); |
| 385 | 387 |
| 386 if (pac_request_) | 388 if (pac_request_) |
| 387 session_->proxy_service()->CancelPacRequest(pac_request_); | 389 session_->proxy_service()->CancelPacRequest(pac_request_); |
| 388 } | 390 } |
| 389 | 391 |
| 390 void HttpNetworkTransaction::DoCallback(int rv) { | 392 void HttpNetworkTransaction::DoCallback(int rv) { |
| 391 DCHECK(rv != ERR_IO_PENDING); | 393 DCHECK(rv != ERR_IO_PENDING); |
| 392 DCHECK(user_callback_); | 394 DCHECK(user_callback_); |
| 393 | 395 |
| 394 // Since Run may result in Read being called, clear user_callback_ up front. | 396 // Since Run may result in Read being called, clear user_callback_ up front. |
| (...skipping 27 matching lines...) Expand all Loading... |
| 422 break; | 424 break; |
| 423 case STATE_INIT_CONNECTION: | 425 case STATE_INIT_CONNECTION: |
| 424 DCHECK_EQ(OK, rv); | 426 DCHECK_EQ(OK, rv); |
| 425 TRACE_EVENT_BEGIN("http.init_conn", request_, request_->url.spec()); | 427 TRACE_EVENT_BEGIN("http.init_conn", request_, request_->url.spec()); |
| 426 rv = DoInitConnection(); | 428 rv = DoInitConnection(); |
| 427 break; | 429 break; |
| 428 case STATE_INIT_CONNECTION_COMPLETE: | 430 case STATE_INIT_CONNECTION_COMPLETE: |
| 429 rv = DoInitConnectionComplete(rv); | 431 rv = DoInitConnectionComplete(rv); |
| 430 TRACE_EVENT_END("http.init_conn", request_, request_->url.spec()); | 432 TRACE_EVENT_END("http.init_conn", request_, request_->url.spec()); |
| 431 break; | 433 break; |
| 434 case STATE_RESOLVE_HOST: |
| 435 DCHECK_EQ(OK, rv); |
| 436 TRACE_EVENT_BEGIN("http.resolve_host", request_, request_->url.spec()); |
| 437 rv = DoResolveHost(); |
| 438 break; |
| 439 case STATE_RESOLVE_HOST_COMPLETE: |
| 440 rv = DoResolveHostComplete(rv); |
| 441 TRACE_EVENT_END("http.resolve_host", request_, request_->url.spec()); |
| 442 break; |
| 443 case STATE_TCP_CONNECT: |
| 444 DCHECK_EQ(OK, rv); |
| 445 TRACE_EVENT_BEGIN("http.connect", request_, request_->url.spec()); |
| 446 rv = DoTCPConnect(); |
| 447 break; |
| 448 case STATE_TCP_CONNECT_COMPLETE: |
| 449 rv = DoTCPConnectComplete(rv); |
| 450 TRACE_EVENT_END("http.connect", request_, request_->url.spec()); |
| 451 break; |
| 432 case STATE_SSL_CONNECT: | 452 case STATE_SSL_CONNECT: |
| 433 DCHECK_EQ(OK, rv); | 453 DCHECK_EQ(OK, rv); |
| 434 TRACE_EVENT_BEGIN("http.ssl_connect", request_, request_->url.spec()); | 454 TRACE_EVENT_BEGIN("http.ssl_connect", request_, request_->url.spec()); |
| 435 rv = DoSSLConnect(); | 455 rv = DoSSLConnect(); |
| 436 break; | 456 break; |
| 437 case STATE_SSL_CONNECT_COMPLETE: | 457 case STATE_SSL_CONNECT_COMPLETE: |
| 438 rv = DoSSLConnectComplete(rv); | 458 rv = DoSSLConnectComplete(rv); |
| 439 TRACE_EVENT_END("http.ssl_connect", request_, request_->url.spec()); | 459 TRACE_EVENT_END("http.ssl_connect", request_, request_->url.spec()); |
| 440 break; | 460 break; |
| 441 case STATE_WRITE_HEADERS: | 461 case STATE_WRITE_HEADERS: |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 531 DCHECK(!connection_.is_initialized()); | 551 DCHECK(!connection_.is_initialized()); |
| 532 | 552 |
| 533 next_state_ = STATE_INIT_CONNECTION_COMPLETE; | 553 next_state_ = STATE_INIT_CONNECTION_COMPLETE; |
| 534 | 554 |
| 535 using_ssl_ = request_->url.SchemeIs("https"); | 555 using_ssl_ = request_->url.SchemeIs("https"); |
| 536 using_proxy_ = !proxy_info_.is_direct() && !using_ssl_; | 556 using_proxy_ = !proxy_info_.is_direct() && !using_ssl_; |
| 537 using_tunnel_ = !proxy_info_.is_direct() && using_ssl_; | 557 using_tunnel_ = !proxy_info_.is_direct() && using_ssl_; |
| 538 | 558 |
| 539 // Build the string used to uniquely identify connections of this type. | 559 // Build the string used to uniquely identify connections of this type. |
| 540 std::string connection_group; | 560 std::string connection_group; |
| 541 std::string host; | 561 if (using_proxy_ || using_tunnel_) |
| 542 int port; | 562 connection_group = "proxy/" + proxy_info_.proxy_server().ToURI() + "/"; |
| 543 if (using_proxy_ || using_tunnel_) { | |
| 544 ProxyServer proxy_server = proxy_info_.proxy_server(); | |
| 545 connection_group = "proxy/" + proxy_server.ToURI() + "/"; | |
| 546 host = proxy_server.HostNoBrackets(); | |
| 547 port = proxy_server.port(); | |
| 548 } else { | |
| 549 host = request_->url.HostNoBrackets(); | |
| 550 port = request_->url.EffectiveIntPort(); | |
| 551 } | |
| 552 if (!using_proxy_) | 563 if (!using_proxy_) |
| 553 connection_group.append(request_->url.GetOrigin().spec()); | 564 connection_group.append(request_->url.GetOrigin().spec()); |
| 554 | 565 |
| 555 DCHECK(!connection_group.empty()); | 566 DCHECK(!connection_group.empty()); |
| 556 int rv = connection_.Init(connection_group, host, port, request_->priority, | 567 return connection_.Init(connection_group, request_->priority, &io_callback_); |
| 557 &io_callback_); | |
| 558 return rv; | |
| 559 } | 568 } |
| 560 | 569 |
| 561 int HttpNetworkTransaction::DoInitConnectionComplete(int result) { | 570 int HttpNetworkTransaction::DoInitConnectionComplete(int result) { |
| 562 if (result < 0) | 571 if (result < 0) |
| 563 return ReconsiderProxyAfterError(result); | 572 return result; |
| 564 | 573 |
| 565 DCHECK(connection_.is_initialized()); | 574 DCHECK(connection_.is_initialized()); |
| 566 | 575 |
| 567 // Set the reused_socket_ flag to indicate that we are using a keep-alive | 576 // Set the reused_socket_ flag to indicate that we are using a keep-alive |
| 568 // connection. This flag is used to handle errors that occur while we are | 577 // connection. This flag is used to handle errors that occur while we are |
| 569 // trying to reuse a keep-alive connection. | 578 // trying to reuse a keep-alive connection. |
| 570 reused_socket_ = connection_.is_reused(); | 579 reused_socket_ = (connection_.socket() != NULL); |
| 571 if (reused_socket_) { | 580 if (reused_socket_) { |
| 572 next_state_ = STATE_WRITE_HEADERS; | 581 next_state_ = STATE_WRITE_HEADERS; |
| 573 } else { | 582 } else { |
| 574 // Now we have a TCP connected socket. Perform other connection setup as | 583 next_state_ = STATE_RESOLVE_HOST; |
| 575 // needed. | 584 } |
| 585 return OK; |
| 586 } |
| 587 |
| 588 int HttpNetworkTransaction::DoResolveHost() { |
| 589 next_state_ = STATE_RESOLVE_HOST_COMPLETE; |
| 590 |
| 591 std::string host; |
| 592 int port; |
| 593 |
| 594 // Determine the host and port to connect to. |
| 595 if (using_proxy_ || using_tunnel_) { |
| 596 ProxyServer proxy_server = proxy_info_.proxy_server(); |
| 597 host = proxy_server.HostNoBrackets(); |
| 598 port = proxy_server.port(); |
| 599 } else { |
| 600 // Direct connection |
| 601 host = request_->url.HostNoBrackets(); |
| 602 port = request_->url.EffectiveIntPort(); |
| 603 } |
| 604 |
| 605 host_resolution_start_time_ = base::Time::Now(); |
| 606 |
| 607 DidStartDnsResolution(host, this); |
| 608 return resolver_.Resolve(host, port, &addresses_, &io_callback_); |
| 609 } |
| 610 |
| 611 int HttpNetworkTransaction::DoResolveHostComplete(int result) { |
| 612 bool ok = (result == OK); |
| 613 DidFinishDnsResolutionWithStatus(ok, request_->referrer, this); |
| 614 if (ok) { |
| 615 next_state_ = STATE_TCP_CONNECT; |
| 616 } else { |
| 617 result = ReconsiderProxyAfterError(result); |
| 618 } |
| 619 return result; |
| 620 } |
| 621 |
| 622 int HttpNetworkTransaction::DoTCPConnect() { |
| 623 next_state_ = STATE_TCP_CONNECT_COMPLETE; |
| 624 |
| 625 DCHECK(!connection_.socket()); |
| 626 |
| 627 connect_start_time_ = base::Time::Now(); |
| 628 |
| 629 ClientSocket* s = socket_factory_->CreateTCPClientSocket(addresses_); |
| 630 connection_.set_socket(s); |
| 631 return connection_.socket()->Connect(&io_callback_); |
| 632 } |
| 633 |
| 634 int HttpNetworkTransaction::DoTCPConnectComplete(int result) { |
| 635 // If we are using a direct SSL connection, then go ahead and establish the |
| 636 // SSL connection, now. Otherwise, we need to first issue a CONNECT request. |
| 637 if (result == OK) { |
| 576 LogTCPConnectedMetrics(); | 638 LogTCPConnectedMetrics(); |
| 577 if (using_ssl_ && !using_tunnel_) { | 639 if (using_ssl_ && !using_tunnel_) { |
| 578 next_state_ = STATE_SSL_CONNECT; | 640 next_state_ = STATE_SSL_CONNECT; |
| 579 } else { | 641 } else { |
| 580 next_state_ = STATE_WRITE_HEADERS; | 642 next_state_ = STATE_WRITE_HEADERS; |
| 581 if (using_tunnel_) | 643 if (using_tunnel_) |
| 582 establishing_tunnel_ = true; | 644 establishing_tunnel_ = true; |
| 583 } | 645 } |
| 646 } else { |
| 647 result = ReconsiderProxyAfterError(result); |
| 584 } | 648 } |
| 585 return OK; | 649 return result; |
| 586 } | 650 } |
| 587 | 651 |
| 588 int HttpNetworkTransaction::DoSSLConnect() { | 652 int HttpNetworkTransaction::DoSSLConnect() { |
| 589 next_state_ = STATE_SSL_CONNECT_COMPLETE; | 653 next_state_ = STATE_SSL_CONNECT_COMPLETE; |
| 590 | 654 |
| 591 // Add a SSL socket on top of our existing transport socket. | 655 // Add a SSL socket on top of our existing transport socket. |
| 592 ClientSocket* s = connection_.release_socket(); | 656 ClientSocket* s = connection_.release_socket(); |
| 593 s = socket_factory_->CreateSSLClientSocket( | 657 s = socket_factory_->CreateSSLClientSocket( |
| 594 s, request_->url.HostNoBrackets(), ssl_config_); | 658 s, request_->url.HostNoBrackets(), ssl_config_); |
| 595 connection_.set_socket(s); | 659 connection_.set_socket(s); |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 876 (response_body_length_ != -1 && | 940 (response_body_length_ != -1 && |
| 877 response_body_read_ > response_body_length_)) | 941 response_body_read_ > response_body_length_)) |
| 878 keep_alive = false; | 942 keep_alive = false; |
| 879 } | 943 } |
| 880 } | 944 } |
| 881 | 945 |
| 882 // Clean up connection_ if we are done. | 946 // Clean up connection_ if we are done. |
| 883 if (done) { | 947 if (done) { |
| 884 LogTransactionMetrics(); | 948 LogTransactionMetrics(); |
| 885 if (!keep_alive) | 949 if (!keep_alive) |
| 886 connection_.socket()->Disconnect(); | 950 connection_.set_socket(NULL); |
| 887 connection_.Reset(); | 951 connection_.Reset(); |
| 888 // The next Read call will return 0 (EOF). | 952 // The next Read call will return 0 (EOF). |
| 889 } | 953 } |
| 890 | 954 |
| 891 // Clear these to avoid leaving around old state. | 955 // Clear these to avoid leaving around old state. |
| 892 read_buf_ = NULL; | 956 read_buf_ = NULL; |
| 893 read_buf_len_ = 0; | 957 read_buf_len_ = 0; |
| 894 | 958 |
| 895 return result; | 959 return result; |
| 896 } | 960 } |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 948 DidDrainBodyForAuthRestart(keep_alive); | 1012 DidDrainBodyForAuthRestart(keep_alive); |
| 949 } else { | 1013 } else { |
| 950 // Keep draining. | 1014 // Keep draining. |
| 951 next_state_ = STATE_DRAIN_BODY_FOR_AUTH_RESTART; | 1015 next_state_ = STATE_DRAIN_BODY_FOR_AUTH_RESTART; |
| 952 } | 1016 } |
| 953 | 1017 |
| 954 return OK; | 1018 return OK; |
| 955 } | 1019 } |
| 956 | 1020 |
| 957 void HttpNetworkTransaction::LogTCPConnectedMetrics() const { | 1021 void HttpNetworkTransaction::LogTCPConnectedMetrics() const { |
| 1022 DCHECK(connect_start_time_ != base::Time()); |
| 1023 base::TimeDelta connect_duration = |
| 1024 base::Time::Now() - connect_start_time_; |
| 1025 |
| 1026 UMA_HISTOGRAM_CLIPPED_TIMES(FieldTrial::MakeName( |
| 1027 "Net.TCP_Connection_Latency", "DnsImpact").data(), connect_duration, |
| 1028 base::TimeDelta::FromMilliseconds(1), base::TimeDelta::FromMinutes(10), |
| 1029 100); |
| 1030 |
| 958 base::TimeDelta host_resolution_and_tcp_connection_latency = | 1031 base::TimeDelta host_resolution_and_tcp_connection_latency = |
| 959 base::Time::Now() - host_resolution_start_time_; | 1032 base::Time::Now() - host_resolution_start_time_; |
| 960 | 1033 |
| 961 UMA_HISTOGRAM_CLIPPED_TIMES( | 1034 UMA_HISTOGRAM_CLIPPED_TIMES( |
| 962 FieldTrial::MakeName( | 1035 FieldTrial::MakeName( |
| 963 "Net.Dns_Resolution_And_TCP_Connection_Latency", "DnsImpact").data(), | 1036 "Net.Dns_Resolution_And_TCP_Connection_Latency", "DnsImpact").data(), |
| 964 host_resolution_and_tcp_connection_latency, | 1037 host_resolution_and_tcp_connection_latency, |
| 965 base::TimeDelta::FromMilliseconds(1), base::TimeDelta::FromMinutes(10), | 1038 base::TimeDelta::FromMilliseconds(1), base::TimeDelta::FromMinutes(10), |
| 966 100); | 1039 100); |
| 967 | 1040 |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1220 } | 1293 } |
| 1221 | 1294 |
| 1222 int HttpNetworkTransaction::HandleSSLHandshakeError(int error) { | 1295 int HttpNetworkTransaction::HandleSSLHandshakeError(int error) { |
| 1223 switch (error) { | 1296 switch (error) { |
| 1224 case ERR_SSL_PROTOCOL_ERROR: | 1297 case ERR_SSL_PROTOCOL_ERROR: |
| 1225 case ERR_SSL_VERSION_OR_CIPHER_MISMATCH: | 1298 case ERR_SSL_VERSION_OR_CIPHER_MISMATCH: |
| 1226 if (ssl_config_.tls1_enabled) { | 1299 if (ssl_config_.tls1_enabled) { |
| 1227 // This could be a TLS-intolerant server or an SSL 3.0 server that | 1300 // This could be a TLS-intolerant server or an SSL 3.0 server that |
| 1228 // chose a TLS-only cipher suite. Turn off TLS 1.0 and retry. | 1301 // chose a TLS-only cipher suite. Turn off TLS 1.0 and retry. |
| 1229 ssl_config_.tls1_enabled = false; | 1302 ssl_config_.tls1_enabled = false; |
| 1230 connection_.socket()->Disconnect(); | 1303 connection_.set_socket(NULL); |
| 1231 connection_.Reset(); | 1304 connection_.Reset(); |
| 1232 next_state_ = STATE_INIT_CONNECTION; | 1305 next_state_ = STATE_INIT_CONNECTION; |
| 1233 error = OK; | 1306 error = OK; |
| 1234 } | 1307 } |
| 1235 break; | 1308 break; |
| 1236 } | 1309 } |
| 1237 return error; | 1310 return error; |
| 1238 } | 1311 } |
| 1239 | 1312 |
| 1240 // This method determines whether it is safe to resend the request after an | 1313 // This method determines whether it is safe to resend the request after an |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1283 // out of the cached keep-alive connections eventually. | 1356 // out of the cached keep-alive connections eventually. |
| 1284 if (establishing_tunnel_ || | 1357 if (establishing_tunnel_ || |
| 1285 !reused_socket_ || // We didn't reuse a keep-alive connection. | 1358 !reused_socket_ || // We didn't reuse a keep-alive connection. |
| 1286 header_buf_len_) { // We have received some response headers. | 1359 header_buf_len_) { // We have received some response headers. |
| 1287 return false; | 1360 return false; |
| 1288 } | 1361 } |
| 1289 return true; | 1362 return true; |
| 1290 } | 1363 } |
| 1291 | 1364 |
| 1292 void HttpNetworkTransaction::ResetConnectionAndRequestForResend() { | 1365 void HttpNetworkTransaction::ResetConnectionAndRequestForResend() { |
| 1293 connection_.socket()->Disconnect(); | 1366 connection_.set_socket(NULL); |
| 1294 connection_.Reset(); | 1367 connection_.Reset(); |
| 1295 // There are two reasons we need to clear request_headers_. 1) It contains | 1368 // There are two reasons we need to clear request_headers_. 1) It contains |
| 1296 // the real request headers, but we may need to resend the CONNECT request | 1369 // the real request headers, but we may need to resend the CONNECT request |
| 1297 // first to recreate the SSL tunnel. 2) An empty request_headers_ causes | 1370 // first to recreate the SSL tunnel. 2) An empty request_headers_ causes |
| 1298 // BuildRequestHeaders to be called, which rewinds request_body_stream_ to | 1371 // BuildRequestHeaders to be called, which rewinds request_body_stream_ to |
| 1299 // the beginning of request_->upload_data. | 1372 // the beginning of request_->upload_data. |
| 1300 request_headers_->headers_.clear(); | 1373 request_headers_->headers_.clear(); |
| 1301 request_headers_bytes_sent_ = 0; | 1374 request_headers_bytes_sent_ = 0; |
| 1302 next_state_ = STATE_INIT_CONNECTION; // Resend the request. | 1375 next_state_ = STATE_INIT_CONNECTION; // Resend the request. |
| 1303 } | 1376 } |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1328 return error; | 1401 return error; |
| 1329 } | 1402 } |
| 1330 | 1403 |
| 1331 if (request_->load_flags & LOAD_BYPASS_PROXY) { | 1404 if (request_->load_flags & LOAD_BYPASS_PROXY) { |
| 1332 return error; | 1405 return error; |
| 1333 } | 1406 } |
| 1334 | 1407 |
| 1335 int rv = session_->proxy_service()->ReconsiderProxyAfterError( | 1408 int rv = session_->proxy_service()->ReconsiderProxyAfterError( |
| 1336 request_->url, &proxy_info_, &io_callback_, &pac_request_); | 1409 request_->url, &proxy_info_, &io_callback_, &pac_request_); |
| 1337 if (rv == OK || rv == ERR_IO_PENDING) { | 1410 if (rv == OK || rv == ERR_IO_PENDING) { |
| 1338 connection_.socket()->Disconnect(); | 1411 connection_.set_socket(NULL); |
| 1339 connection_.Reset(); | 1412 connection_.Reset(); |
| 1340 DCHECK(!request_headers_bytes_sent_); | 1413 DCHECK(!request_headers_bytes_sent_); |
| 1341 next_state_ = STATE_RESOLVE_PROXY_COMPLETE; | 1414 next_state_ = STATE_RESOLVE_PROXY_COMPLETE; |
| 1342 } else { | 1415 } else { |
| 1343 rv = error; | 1416 rv = error; |
| 1344 } | 1417 } |
| 1345 | 1418 |
| 1346 return rv; | 1419 return rv; |
| 1347 } | 1420 } |
| 1348 | 1421 |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1608 if (target == HttpAuth::AUTH_PROXY) { | 1681 if (target == HttpAuth::AUTH_PROXY) { |
| 1609 auth_info->host = ASCIIToWide(proxy_info_.proxy_server().host_and_port()); | 1682 auth_info->host = ASCIIToWide(proxy_info_.proxy_server().host_and_port()); |
| 1610 } else { | 1683 } else { |
| 1611 DCHECK(target == HttpAuth::AUTH_SERVER); | 1684 DCHECK(target == HttpAuth::AUTH_SERVER); |
| 1612 auth_info->host = ASCIIToWide(request_->url.host()); | 1685 auth_info->host = ASCIIToWide(request_->url.host()); |
| 1613 } | 1686 } |
| 1614 response_.auth_challenge = auth_info; | 1687 response_.auth_challenge = auth_info; |
| 1615 } | 1688 } |
| 1616 | 1689 |
| 1617 } // namespace net | 1690 } // namespace net |
| OLD | NEW |