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