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_network_transaction.h" | 5 #include "net/http/http_network_transaction.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
555 OnIOComplete(ERR_SSL_CLIENT_AUTH_CERT_NEEDED); | 555 OnIOComplete(ERR_SSL_CLIENT_AUTH_CERT_NEEDED); |
556 } | 556 } |
557 | 557 |
558 void HttpNetworkTransaction::OnHttpsProxyTunnelResponse( | 558 void HttpNetworkTransaction::OnHttpsProxyTunnelResponse( |
559 const HttpResponseInfo& response_info, | 559 const HttpResponseInfo& response_info, |
560 const SSLConfig& used_ssl_config, | 560 const SSLConfig& used_ssl_config, |
561 const ProxyInfo& used_proxy_info, | 561 const ProxyInfo& used_proxy_info, |
562 HttpStream* stream) { | 562 HttpStream* stream) { |
563 DCHECK_EQ(STATE_CREATE_STREAM_COMPLETE, next_state_); | 563 DCHECK_EQ(STATE_CREATE_STREAM_COMPLETE, next_state_); |
564 | 564 |
| 565 CopyConnectionAttempts(); |
| 566 |
565 headers_valid_ = true; | 567 headers_valid_ = true; |
566 response_ = response_info; | 568 response_ = response_info; |
567 server_ssl_config_ = used_ssl_config; | 569 server_ssl_config_ = used_ssl_config; |
568 proxy_info_ = used_proxy_info; | 570 proxy_info_ = used_proxy_info; |
569 if (stream_) | 571 if (stream_) |
570 total_received_bytes_ += stream_->GetTotalReceivedBytes(); | 572 total_received_bytes_ += stream_->GetTotalReceivedBytes(); |
571 stream_.reset(stream); | 573 stream_.reset(stream); |
572 stream_request_.reset(); // we're done with the stream request | 574 stream_request_.reset(); // we're done with the stream request |
573 OnIOComplete(ERR_HTTPS_PROXY_TUNNEL_RESPONSE); | 575 OnIOComplete(ERR_HTTPS_PROXY_TUNNEL_RESPONSE); |
574 } | 576 } |
575 | 577 |
| 578 const ClientSocketHandle::ConnectionAttempts& |
| 579 HttpNetworkTransaction::connection_attempts() const { |
| 580 return connection_attempts_; |
| 581 } |
| 582 |
576 bool HttpNetworkTransaction::IsSecureRequest() const { | 583 bool HttpNetworkTransaction::IsSecureRequest() const { |
577 return request_->url.SchemeIsSecure(); | 584 return request_->url.SchemeIsSecure(); |
578 } | 585 } |
579 | 586 |
580 bool HttpNetworkTransaction::UsingHttpProxyWithoutTunnel() const { | 587 bool HttpNetworkTransaction::UsingHttpProxyWithoutTunnel() const { |
581 return (proxy_info_.is_http() || proxy_info_.is_https() || | 588 return (proxy_info_.is_http() || proxy_info_.is_https() || |
582 proxy_info_.is_quic()) && | 589 proxy_info_.is_quic()) && |
583 !(request_->url.SchemeIs("https") || request_->url.SchemeIsWSOrWSS()); | 590 !(request_->url.SchemeIs("https") || request_->url.SchemeIsWSOrWSS()); |
584 } | 591 } |
585 | 592 |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
746 server_ssl_config_, | 753 server_ssl_config_, |
747 proxy_ssl_config_, | 754 proxy_ssl_config_, |
748 this, | 755 this, |
749 net_log_)); | 756 net_log_)); |
750 } | 757 } |
751 DCHECK(stream_request_.get()); | 758 DCHECK(stream_request_.get()); |
752 return ERR_IO_PENDING; | 759 return ERR_IO_PENDING; |
753 } | 760 } |
754 | 761 |
755 int HttpNetworkTransaction::DoCreateStreamComplete(int result) { | 762 int HttpNetworkTransaction::DoCreateStreamComplete(int result) { |
| 763 if (result != ERR_HTTPS_PROXY_TUNNEL_RESPONSE) |
| 764 CopyConnectionAttempts(); |
| 765 |
756 if (result == OK) { | 766 if (result == OK) { |
757 next_state_ = STATE_INIT_STREAM; | 767 next_state_ = STATE_INIT_STREAM; |
758 DCHECK(stream_.get()); | 768 DCHECK(stream_.get()); |
759 } else if (result == ERR_SSL_CLIENT_AUTH_CERT_NEEDED) { | 769 } else if (result == ERR_SSL_CLIENT_AUTH_CERT_NEEDED) { |
760 result = HandleCertificateRequest(result); | 770 result = HandleCertificateRequest(result); |
761 } else if (result == ERR_HTTPS_PROXY_TUNNEL_RESPONSE) { | 771 } else if (result == ERR_HTTPS_PROXY_TUNNEL_RESPONSE) { |
762 // Return OK and let the caller read the proxy's error page | 772 // Return OK and let the caller read the proxy's error page |
763 next_state_ = STATE_NONE; | 773 next_state_ = STATE_NONE; |
764 return OK; | 774 return OK; |
765 } else if (result == ERR_HTTP_1_1_REQUIRED || | 775 } else if (result == ERR_HTTP_1_1_REQUIRED || |
(...skipping 771 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1537 default: | 1547 default: |
1538 description = base::StringPrintf("Unknown state 0x%08X (%u)", state, | 1548 description = base::StringPrintf("Unknown state 0x%08X (%u)", state, |
1539 state); | 1549 state); |
1540 break; | 1550 break; |
1541 } | 1551 } |
1542 return description; | 1552 return description; |
1543 } | 1553 } |
1544 | 1554 |
1545 #undef STATE_CASE | 1555 #undef STATE_CASE |
1546 | 1556 |
| 1557 void HttpNetworkTransaction::CopyConnectionAttempts() { |
| 1558 DCHECK(stream_request_); |
| 1559 |
| 1560 for (const auto& attempt : stream_request_->connection_attempts()) |
| 1561 connection_attempts_.push_back(attempt); |
| 1562 } |
| 1563 |
1547 } // namespace net | 1564 } // namespace net |
OLD | NEW |