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 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 SIMPLE_STATS_COUNTER("HttpNetworkTransaction.Count"); | 166 SIMPLE_STATS_COUNTER("HttpNetworkTransaction.Count"); |
167 | 167 |
168 net_log_ = net_log; | 168 net_log_ = net_log; |
169 request_ = request_info; | 169 request_ = request_info; |
170 | 170 |
171 if (request_->load_flags & LOAD_DISABLE_CERT_REVOCATION_CHECKING) { | 171 if (request_->load_flags & LOAD_DISABLE_CERT_REVOCATION_CHECKING) { |
172 server_ssl_config_.rev_checking_enabled = false; | 172 server_ssl_config_.rev_checking_enabled = false; |
173 proxy_ssl_config_.rev_checking_enabled = false; | 173 proxy_ssl_config_.rev_checking_enabled = false; |
174 } | 174 } |
175 | 175 |
| 176 if (request_->load_flags & LOAD_PREFETCH) |
| 177 response_.unused_since_prefetch = true; |
| 178 |
176 // Channel ID is disabled if privacy mode is enabled for this request. | 179 // Channel ID is disabled if privacy mode is enabled for this request. |
177 if (request_->privacy_mode == PRIVACY_MODE_ENABLED) | 180 if (request_->privacy_mode == PRIVACY_MODE_ENABLED) |
178 server_ssl_config_.channel_id_enabled = false; | 181 server_ssl_config_.channel_id_enabled = false; |
179 | 182 |
180 next_state_ = STATE_NOTIFY_BEFORE_CREATE_STREAM; | 183 next_state_ = STATE_NOTIFY_BEFORE_CREATE_STREAM; |
181 int rv = DoLoop(OK); | 184 int rv = DoLoop(OK); |
182 if (rv == ERR_IO_PENDING) | 185 if (rv == ERR_IO_PENDING) |
183 callback_ = callback; | 186 callback_ = callback; |
184 return rv; | 187 return rv; |
185 } | 188 } |
(...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
739 int HttpNetworkTransaction::DoCreateStreamComplete(int result) { | 742 int HttpNetworkTransaction::DoCreateStreamComplete(int result) { |
740 if (result == OK) { | 743 if (result == OK) { |
741 next_state_ = STATE_INIT_STREAM; | 744 next_state_ = STATE_INIT_STREAM; |
742 DCHECK(stream_.get()); | 745 DCHECK(stream_.get()); |
743 } else if (result == ERR_SSL_CLIENT_AUTH_CERT_NEEDED) { | 746 } else if (result == ERR_SSL_CLIENT_AUTH_CERT_NEEDED) { |
744 result = HandleCertificateRequest(result); | 747 result = HandleCertificateRequest(result); |
745 } else if (result == ERR_HTTPS_PROXY_TUNNEL_RESPONSE) { | 748 } else if (result == ERR_HTTPS_PROXY_TUNNEL_RESPONSE) { |
746 // Return OK and let the caller read the proxy's error page | 749 // Return OK and let the caller read the proxy's error page |
747 next_state_ = STATE_NONE; | 750 next_state_ = STATE_NONE; |
748 return OK; | 751 return OK; |
| 752 } else if (result == ERR_HTTP_1_1_REQUIRED || |
| 753 result == ERR_PROXY_HTTP_1_1_REQUIRED) { |
| 754 return HandleHttp11Required(result); |
749 } | 755 } |
750 | 756 |
751 // Handle possible handshake errors that may have occurred if the stream | 757 // Handle possible handshake errors that may have occurred if the stream |
752 // used SSL for one or more of the layers. | 758 // used SSL for one or more of the layers. |
753 result = HandleSSLHandshakeError(result); | 759 result = HandleSSLHandshakeError(result); |
754 | 760 |
755 // At this point we are done with the stream_request_. | 761 // At this point we are done with the stream_request_. |
756 stream_request_.reset(); | 762 stream_request_.reset(); |
757 return result; | 763 return result; |
758 } | 764 } |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
954 // TODO(wtc): Need a test case for this code path! | 960 // TODO(wtc): Need a test case for this code path! |
955 DCHECK(stream_.get()); | 961 DCHECK(stream_.get()); |
956 DCHECK(is_https_request()); | 962 DCHECK(is_https_request()); |
957 response_.cert_request_info = new SSLCertRequestInfo; | 963 response_.cert_request_info = new SSLCertRequestInfo; |
958 stream_->GetSSLCertRequestInfo(response_.cert_request_info.get()); | 964 stream_->GetSSLCertRequestInfo(response_.cert_request_info.get()); |
959 result = HandleCertificateRequest(result); | 965 result = HandleCertificateRequest(result); |
960 if (result == OK) | 966 if (result == OK) |
961 return result; | 967 return result; |
962 } | 968 } |
963 | 969 |
| 970 if (result == ERR_HTTP_1_1_REQUIRED || |
| 971 result == ERR_PROXY_HTTP_1_1_REQUIRED) { |
| 972 return HandleHttp11Required(result); |
| 973 } |
| 974 |
964 // ERR_CONNECTION_CLOSED is treated differently at this point; if partial | 975 // ERR_CONNECTION_CLOSED is treated differently at this point; if partial |
965 // response headers were received, we do the best we can to make sense of it | 976 // response headers were received, we do the best we can to make sense of it |
966 // and send it back up the stack. | 977 // and send it back up the stack. |
967 // | 978 // |
968 // TODO(davidben): Consider moving this to HttpBasicStream, It's a little | 979 // TODO(davidben): Consider moving this to HttpBasicStream, It's a little |
969 // bizarre for SPDY. Assuming this logic is useful at all. | 980 // bizarre for SPDY. Assuming this logic is useful at all. |
970 // TODO(davidben): Bubble the error code up so we do not cache? | 981 // TODO(davidben): Bubble the error code up so we do not cache? |
971 if (result == ERR_CONNECTION_CLOSED && response_.headers.get()) | 982 if (result == ERR_CONNECTION_CLOSED && response_.headers.get()) |
972 result = OK; | 983 result = OK; |
973 | 984 |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1188 &proxy_ssl_config_ : &server_ssl_config_; | 1199 &proxy_ssl_config_ : &server_ssl_config_; |
1189 ssl_config->send_client_cert = true; | 1200 ssl_config->send_client_cert = true; |
1190 ssl_config->client_cert = client_cert; | 1201 ssl_config->client_cert = client_cert; |
1191 next_state_ = STATE_CREATE_STREAM; | 1202 next_state_ = STATE_CREATE_STREAM; |
1192 // Reset the other member variables. | 1203 // Reset the other member variables. |
1193 // Note: this is necessary only with SSL renegotiation. | 1204 // Note: this is necessary only with SSL renegotiation. |
1194 ResetStateForRestart(); | 1205 ResetStateForRestart(); |
1195 return OK; | 1206 return OK; |
1196 } | 1207 } |
1197 | 1208 |
| 1209 int HttpNetworkTransaction::HandleHttp11Required(int error) { |
| 1210 DCHECK(error == ERR_HTTP_1_1_REQUIRED || |
| 1211 error == ERR_PROXY_HTTP_1_1_REQUIRED); |
| 1212 |
| 1213 if (error == ERR_HTTP_1_1_REQUIRED) { |
| 1214 HttpServerProperties::ForceHTTP11(&server_ssl_config_); |
| 1215 } else { |
| 1216 HttpServerProperties::ForceHTTP11(&proxy_ssl_config_); |
| 1217 } |
| 1218 ResetConnectionAndRequestForResend(); |
| 1219 return OK; |
| 1220 } |
| 1221 |
1198 void HttpNetworkTransaction::HandleClientAuthError(int error) { | 1222 void HttpNetworkTransaction::HandleClientAuthError(int error) { |
1199 if (server_ssl_config_.send_client_cert && | 1223 if (server_ssl_config_.send_client_cert && |
1200 (error == ERR_SSL_PROTOCOL_ERROR || IsClientCertificateError(error))) { | 1224 (error == ERR_SSL_PROTOCOL_ERROR || IsClientCertificateError(error))) { |
1201 session_->ssl_client_auth_cache()->Remove( | 1225 session_->ssl_client_auth_cache()->Remove( |
1202 HostPortPair::FromURL(request_->url)); | 1226 HostPortPair::FromURL(request_->url)); |
1203 } | 1227 } |
1204 } | 1228 } |
1205 | 1229 |
1206 // TODO(rch): This does not correctly handle errors when an SSL proxy is | 1230 // TODO(rch): This does not correctly handle errors when an SSL proxy is |
1207 // being used, as all of the errors are handled as if they were generated | 1231 // being used, as all of the errors are handled as if they were generated |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1501 description = base::StringPrintf("Unknown state 0x%08X (%u)", state, | 1525 description = base::StringPrintf("Unknown state 0x%08X (%u)", state, |
1502 state); | 1526 state); |
1503 break; | 1527 break; |
1504 } | 1528 } |
1505 return description; | 1529 return description; |
1506 } | 1530 } |
1507 | 1531 |
1508 #undef STATE_CASE | 1532 #undef STATE_CASE |
1509 | 1533 |
1510 } // namespace net | 1534 } // namespace net |
OLD | NEW |