| 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 <memory> | 7 #include <memory> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 fallback_error_code_(ERR_SSL_INAPPROPRIATE_FALLBACK), | 114 fallback_error_code_(ERR_SSL_INAPPROPRIATE_FALLBACK), |
| 115 fallback_failure_state_(SSL_FAILURE_NONE), | 115 fallback_failure_state_(SSL_FAILURE_NONE), |
| 116 request_headers_(), | 116 request_headers_(), |
| 117 read_buf_len_(0), | 117 read_buf_len_(0), |
| 118 total_received_bytes_(0), | 118 total_received_bytes_(0), |
| 119 total_sent_bytes_(0), | 119 total_sent_bytes_(0), |
| 120 next_state_(STATE_NONE), | 120 next_state_(STATE_NONE), |
| 121 establishing_tunnel_(false), | 121 establishing_tunnel_(false), |
| 122 websocket_handshake_stream_base_create_helper_(NULL), | 122 websocket_handshake_stream_base_create_helper_(NULL), |
| 123 net_error_details_() { | 123 net_error_details_() { |
| 124 session->ssl_config_service()->GetSSLConfig(&server_ssl_config_); | |
| 125 session->GetAlpnProtos(&server_ssl_config_.alpn_protos); | |
| 126 session->GetNpnProtos(&server_ssl_config_.npn_protos); | |
| 127 proxy_ssl_config_ = server_ssl_config_; | |
| 128 } | 124 } |
| 129 | 125 |
| 130 HttpNetworkTransaction::~HttpNetworkTransaction() { | 126 HttpNetworkTransaction::~HttpNetworkTransaction() { |
| 131 if (stream_.get()) { | 127 if (stream_.get()) { |
| 132 // TODO(mbelshe): The stream_ should be able to compute whether or not the | 128 // TODO(mbelshe): The stream_ should be able to compute whether or not the |
| 133 // stream should be kept alive. No reason to compute here | 129 // stream should be kept alive. No reason to compute here |
| 134 // and pass it in. | 130 // and pass it in. |
| 135 if (!stream_->CanReuseConnection() || next_state_ != STATE_NONE) { | 131 if (!stream_->CanReuseConnection() || next_state_ != STATE_NONE) { |
| 136 stream_->Close(true /* not reusable */); | 132 stream_->Close(true /* not reusable */); |
| 137 } else if (stream_->IsResponseBodyComplete()) { | 133 } else if (stream_->IsResponseBodyComplete()) { |
| 138 // If the response body is complete, we can just reuse the socket. | 134 // If the response body is complete, we can just reuse the socket. |
| 139 stream_->Close(false /* reusable */); | 135 stream_->Close(false /* reusable */); |
| 140 } else { | 136 } else { |
| 141 // Otherwise, we try to drain the response body. | 137 // Otherwise, we try to drain the response body. |
| 142 HttpStream* stream = stream_.release(); | 138 HttpStream* stream = stream_.release(); |
| 143 stream->Drain(session_); | 139 stream->Drain(session_); |
| 144 } | 140 } |
| 145 } | 141 } |
| 146 | 142 |
| 147 if (request_ && request_->upload_data_stream) | 143 if (request_ && request_->upload_data_stream) |
| 148 request_->upload_data_stream->Reset(); // Invalidate pending callbacks. | 144 request_->upload_data_stream->Reset(); // Invalidate pending callbacks. |
| 149 } | 145 } |
| 150 | 146 |
| 151 int HttpNetworkTransaction::Start(const HttpRequestInfo* request_info, | 147 int HttpNetworkTransaction::Start(const HttpRequestInfo* request_info, |
| 152 const CompletionCallback& callback, | 148 const CompletionCallback& callback, |
| 153 const BoundNetLog& net_log) { | 149 const BoundNetLog& net_log) { |
| 154 net_log_ = net_log; | 150 net_log_ = net_log; |
| 155 request_ = request_info; | 151 request_ = request_info; |
| 156 | 152 |
| 153 // Now that we have an HttpRequestInfo object, update server_ssl_config_. |
| 154 session_->GetSSLConfig(*request_, &server_ssl_config_, &proxy_ssl_config_); |
| 155 |
| 157 if (request_->load_flags & LOAD_DISABLE_CERT_REVOCATION_CHECKING) { | 156 if (request_->load_flags & LOAD_DISABLE_CERT_REVOCATION_CHECKING) { |
| 158 server_ssl_config_.rev_checking_enabled = false; | 157 server_ssl_config_.rev_checking_enabled = false; |
| 159 proxy_ssl_config_.rev_checking_enabled = false; | 158 proxy_ssl_config_.rev_checking_enabled = false; |
| 160 } | 159 } |
| 161 | 160 |
| 162 if (request_->load_flags & LOAD_PREFETCH) | 161 if (request_->load_flags & LOAD_PREFETCH) |
| 163 response_.unused_since_prefetch = true; | 162 response_.unused_since_prefetch = true; |
| 164 | 163 |
| 165 // Channel ID is disabled if privacy mode is enabled for this request. | |
| 166 if (request_->privacy_mode == PRIVACY_MODE_ENABLED) { | |
| 167 server_ssl_config_.channel_id_enabled = false; | |
| 168 } else if (session_->params().enable_token_binding && | |
| 169 session_->params().channel_id_service) { | |
| 170 server_ssl_config_.token_binding_params.push_back(TB_PARAM_ECDSAP256); | |
| 171 } | |
| 172 | |
| 173 next_state_ = STATE_NOTIFY_BEFORE_CREATE_STREAM; | 164 next_state_ = STATE_NOTIFY_BEFORE_CREATE_STREAM; |
| 174 int rv = DoLoop(OK); | 165 int rv = DoLoop(OK); |
| 175 if (rv == ERR_IO_PENDING) | 166 if (rv == ERR_IO_PENDING) |
| 176 callback_ = callback; | 167 callback_ = callback; |
| 177 return rv; | 168 return rv; |
| 178 } | 169 } |
| 179 | 170 |
| 180 int HttpNetworkTransaction::RestartIgnoringLastError( | 171 int HttpNetworkTransaction::RestartIgnoringLastError( |
| 181 const CompletionCallback& callback) { | 172 const CompletionCallback& callback) { |
| 182 DCHECK(!stream_.get()); | 173 DCHECK(!stream_.get()); |
| (...skipping 1621 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1804 DCHECK(stream_request_); | 1795 DCHECK(stream_request_); |
| 1805 | 1796 |
| 1806 // Since the transaction can restart with auth credentials, it may create a | 1797 // Since the transaction can restart with auth credentials, it may create a |
| 1807 // stream more than once. Accumulate all of the connection attempts across | 1798 // stream more than once. Accumulate all of the connection attempts across |
| 1808 // those streams by appending them to the vector: | 1799 // those streams by appending them to the vector: |
| 1809 for (const auto& attempt : stream_request_->connection_attempts()) | 1800 for (const auto& attempt : stream_request_->connection_attempts()) |
| 1810 connection_attempts_.push_back(attempt); | 1801 connection_attempts_.push_back(attempt); |
| 1811 } | 1802 } |
| 1812 | 1803 |
| 1813 } // namespace net | 1804 } // namespace net |
| OLD | NEW |