| 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 <utility> | 8 #include <utility> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 #include "net/ssl/ssl_connection_status_flags.h" | 64 #include "net/ssl/ssl_connection_status_flags.h" |
| 65 #include "net/ssl/ssl_private_key.h" | 65 #include "net/ssl/ssl_private_key.h" |
| 66 #include "net/ssl/token_binding.h" | 66 #include "net/ssl/token_binding.h" |
| 67 #include "url/gurl.h" | 67 #include "url/gurl.h" |
| 68 #include "url/url_canon.h" | 68 #include "url/url_canon.h" |
| 69 | 69 |
| 70 namespace net { | 70 namespace net { |
| 71 | 71 |
| 72 namespace { | 72 namespace { |
| 73 | 73 |
| 74 void ProcessAlternativeServices(HttpNetworkSession* session, | |
| 75 const HttpResponseHeaders& headers, | |
| 76 const HostPortPair& http_host_port_pair) { | |
| 77 if (session->params().parse_alternative_services) { | |
| 78 if (headers.HasHeader(kAlternativeServiceHeader)) { | |
| 79 std::string alternative_service_str; | |
| 80 headers.GetNormalizedHeader(kAlternativeServiceHeader, | |
| 81 &alternative_service_str); | |
| 82 session->http_stream_factory()->ProcessAlternativeService( | |
| 83 session->http_server_properties(), alternative_service_str, | |
| 84 http_host_port_pair, *session); | |
| 85 } | |
| 86 // If "Alt-Svc" is enabled, then ignore "Alternate-Protocol". | |
| 87 return; | |
| 88 } | |
| 89 | |
| 90 if (!headers.HasHeader(kAlternateProtocolHeader)) | |
| 91 return; | |
| 92 | |
| 93 std::vector<std::string> alternate_protocol_values; | |
| 94 size_t iter = 0; | |
| 95 std::string alternate_protocol_str; | |
| 96 while (headers.EnumerateHeader(&iter, kAlternateProtocolHeader, | |
| 97 &alternate_protocol_str)) { | |
| 98 base::TrimWhitespaceASCII(alternate_protocol_str, base::TRIM_ALL, | |
| 99 &alternate_protocol_str); | |
| 100 if (!alternate_protocol_str.empty()) { | |
| 101 alternate_protocol_values.push_back(alternate_protocol_str); | |
| 102 } | |
| 103 } | |
| 104 | |
| 105 session->http_stream_factory()->ProcessAlternateProtocol( | |
| 106 session->http_server_properties(), | |
| 107 alternate_protocol_values, | |
| 108 http_host_port_pair, | |
| 109 *session); | |
| 110 } | |
| 111 | |
| 112 scoped_ptr<base::Value> NetLogSSLVersionFallbackCallback( | 74 scoped_ptr<base::Value> NetLogSSLVersionFallbackCallback( |
| 113 const GURL* url, | 75 const GURL* url, |
| 114 int net_error, | 76 int net_error, |
| 115 SSLFailureState ssl_failure_state, | 77 SSLFailureState ssl_failure_state, |
| 116 uint16_t version_before, | 78 uint16_t version_before, |
| 117 uint16_t version_after, | 79 uint16_t version_after, |
| 118 NetLogCaptureMode /* capture_mode */) { | 80 NetLogCaptureMode /* capture_mode */) { |
| 119 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); | 81 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
| 120 dict->SetString("host_and_port", GetHostAndPort(*url)); | 82 dict->SetString("host_and_port", GetHostAndPort(*url)); |
| 121 dict->SetInteger("net_error", net_error); | 83 dict->SetInteger("net_error", net_error); |
| (...skipping 1109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1231 // We treat any other 1xx in this same way (although in practice getting | 1193 // We treat any other 1xx in this same way (although in practice getting |
| 1232 // a 1xx that isn't a 100 is rare). | 1194 // a 1xx that isn't a 100 is rare). |
| 1233 // Unless this is a WebSocket request, in which case we pass it on up. | 1195 // Unless this is a WebSocket request, in which case we pass it on up. |
| 1234 if (response_.headers->response_code() / 100 == 1 && | 1196 if (response_.headers->response_code() / 100 == 1 && |
| 1235 !ForWebSocketHandshake()) { | 1197 !ForWebSocketHandshake()) { |
| 1236 response_.headers = new HttpResponseHeaders(std::string()); | 1198 response_.headers = new HttpResponseHeaders(std::string()); |
| 1237 next_state_ = STATE_READ_HEADERS; | 1199 next_state_ = STATE_READ_HEADERS; |
| 1238 return OK; | 1200 return OK; |
| 1239 } | 1201 } |
| 1240 | 1202 |
| 1241 ProcessAlternativeServices(session_, *response_.headers.get(), | 1203 session_->http_stream_factory()->ProcessAlternativeServices( |
| 1242 HostPortPair::FromURL(request_->url)); | 1204 session_, response_.headers.get(), HostPortPair::FromURL(request_->url)); |
| 1243 | 1205 |
| 1244 int rv = HandleAuthChallenge(); | 1206 int rv = HandleAuthChallenge(); |
| 1245 if (rv != OK) | 1207 if (rv != OK) |
| 1246 return rv; | 1208 return rv; |
| 1247 | 1209 |
| 1248 if (IsSecureRequest()) | 1210 if (IsSecureRequest()) |
| 1249 stream_->GetSSLInfo(&response_.ssl_info); | 1211 stream_->GetSSLInfo(&response_.ssl_info); |
| 1250 | 1212 |
| 1251 headers_valid_ = true; | 1213 headers_valid_ = true; |
| 1252 return OK; | 1214 return OK; |
| (...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1793 DCHECK(stream_request_); | 1755 DCHECK(stream_request_); |
| 1794 | 1756 |
| 1795 // Since the transaction can restart with auth credentials, it may create a | 1757 // Since the transaction can restart with auth credentials, it may create a |
| 1796 // stream more than once. Accumulate all of the connection attempts across | 1758 // stream more than once. Accumulate all of the connection attempts across |
| 1797 // those streams by appending them to the vector: | 1759 // those streams by appending them to the vector: |
| 1798 for (const auto& attempt : stream_request_->connection_attempts()) | 1760 for (const auto& attempt : stream_request_->connection_attempts()) |
| 1799 connection_attempts_.push_back(attempt); | 1761 connection_attempts_.push_back(attempt); |
| 1800 } | 1762 } |
| 1801 | 1763 |
| 1802 } // namespace net | 1764 } // namespace net |
| OLD | NEW |