| 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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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, | 74 void ProcessAlternativeServices(HttpNetworkSession* session, |
| 75 const HttpResponseHeaders& headers, | 75 const HttpResponseHeaders& headers, |
| 76 const HostPortPair& http_host_port_pair) { | 76 const SchemeOriginPair& scheme_origin_pair) { |
| 77 if (session->params().parse_alternative_services) { | 77 if (session->params().parse_alternative_services) { |
| 78 if (headers.HasHeader(kAlternativeServiceHeader)) { | 78 if (headers.HasHeader(kAlternativeServiceHeader)) { |
| 79 std::string alternative_service_str; | 79 std::string alternative_service_str; |
| 80 headers.GetNormalizedHeader(kAlternativeServiceHeader, | 80 headers.GetNormalizedHeader(kAlternativeServiceHeader, |
| 81 &alternative_service_str); | 81 &alternative_service_str); |
| 82 session->http_stream_factory()->ProcessAlternativeService( | 82 session->http_stream_factory()->ProcessAlternativeService( |
| 83 session->http_server_properties(), alternative_service_str, | 83 session->http_server_properties(), alternative_service_str, |
| 84 http_host_port_pair, *session); | 84 scheme_origin_pair, *session); |
| 85 } | 85 } |
| 86 // If "Alt-Svc" is enabled, then ignore "Alternate-Protocol". | 86 // If "Alt-Svc" is enabled, then ignore "Alternate-Protocol". |
| 87 return; | 87 return; |
| 88 } | 88 } |
| 89 | 89 |
| 90 if (!headers.HasHeader(kAlternateProtocolHeader)) | 90 if (!headers.HasHeader(kAlternateProtocolHeader)) |
| 91 return; | 91 return; |
| 92 | 92 |
| 93 std::vector<std::string> alternate_protocol_values; | 93 std::vector<std::string> alternate_protocol_values; |
| 94 size_t iter = 0; | 94 size_t iter = 0; |
| 95 std::string alternate_protocol_str; | 95 std::string alternate_protocol_str; |
| 96 while (headers.EnumerateHeader(&iter, kAlternateProtocolHeader, | 96 while (headers.EnumerateHeader(&iter, kAlternateProtocolHeader, |
| 97 &alternate_protocol_str)) { | 97 &alternate_protocol_str)) { |
| 98 base::TrimWhitespaceASCII(alternate_protocol_str, base::TRIM_ALL, | 98 base::TrimWhitespaceASCII(alternate_protocol_str, base::TRIM_ALL, |
| 99 &alternate_protocol_str); | 99 &alternate_protocol_str); |
| 100 if (!alternate_protocol_str.empty()) { | 100 if (!alternate_protocol_str.empty()) { |
| 101 alternate_protocol_values.push_back(alternate_protocol_str); | 101 alternate_protocol_values.push_back(alternate_protocol_str); |
| 102 } | 102 } |
| 103 } | 103 } |
| 104 | 104 |
| 105 session->http_stream_factory()->ProcessAlternateProtocol( | 105 session->http_stream_factory()->ProcessAlternateProtocol( |
| 106 session->http_server_properties(), | 106 session->http_server_properties(), alternate_protocol_values, |
| 107 alternate_protocol_values, | 107 scheme_origin_pair, *session); |
| 108 http_host_port_pair, | |
| 109 *session); | |
| 110 } | 108 } |
| 111 | 109 |
| 112 scoped_ptr<base::Value> NetLogSSLVersionFallbackCallback( | 110 scoped_ptr<base::Value> NetLogSSLVersionFallbackCallback( |
| 113 const GURL* url, | 111 const GURL* url, |
| 114 int net_error, | 112 int net_error, |
| 115 SSLFailureState ssl_failure_state, | 113 SSLFailureState ssl_failure_state, |
| 116 uint16_t version_before, | 114 uint16_t version_before, |
| 117 uint16_t version_after, | 115 uint16_t version_after, |
| 118 NetLogCaptureMode /* capture_mode */) { | 116 NetLogCaptureMode /* capture_mode */) { |
| 119 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); | 117 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
| (...skipping 1111 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 | 1229 // We treat any other 1xx in this same way (although in practice getting |
| 1232 // a 1xx that isn't a 100 is rare). | 1230 // a 1xx that isn't a 100 is rare). |
| 1233 // Unless this is a WebSocket request, in which case we pass it on up. | 1231 // Unless this is a WebSocket request, in which case we pass it on up. |
| 1234 if (response_.headers->response_code() / 100 == 1 && | 1232 if (response_.headers->response_code() / 100 == 1 && |
| 1235 !ForWebSocketHandshake()) { | 1233 !ForWebSocketHandshake()) { |
| 1236 response_.headers = new HttpResponseHeaders(std::string()); | 1234 response_.headers = new HttpResponseHeaders(std::string()); |
| 1237 next_state_ = STATE_READ_HEADERS; | 1235 next_state_ = STATE_READ_HEADERS; |
| 1238 return OK; | 1236 return OK; |
| 1239 } | 1237 } |
| 1240 | 1238 |
| 1239 SchemeOriginPair scheme_origin_pair = |
| 1240 SchemeOriginPair::FromURL(request_->url); |
| 1241 |
| 1241 ProcessAlternativeServices(session_, *response_.headers.get(), | 1242 ProcessAlternativeServices(session_, *response_.headers.get(), |
| 1242 HostPortPair::FromURL(request_->url)); | 1243 scheme_origin_pair); |
| 1243 | 1244 |
| 1244 int rv = HandleAuthChallenge(); | 1245 int rv = HandleAuthChallenge(); |
| 1245 if (rv != OK) | 1246 if (rv != OK) |
| 1246 return rv; | 1247 return rv; |
| 1247 | 1248 |
| 1248 if (IsSecureRequest()) | 1249 if (IsSecureRequest()) |
| 1249 stream_->GetSSLInfo(&response_.ssl_info); | 1250 stream_->GetSSLInfo(&response_.ssl_info); |
| 1250 | 1251 |
| 1251 headers_valid_ = true; | 1252 headers_valid_ = true; |
| 1252 return OK; | 1253 return OK; |
| (...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1793 DCHECK(stream_request_); | 1794 DCHECK(stream_request_); |
| 1794 | 1795 |
| 1795 // Since the transaction can restart with auth credentials, it may create a | 1796 // Since the transaction can restart with auth credentials, it may create a |
| 1796 // stream more than once. Accumulate all of the connection attempts across | 1797 // stream more than once. Accumulate all of the connection attempts across |
| 1797 // those streams by appending them to the vector: | 1798 // those streams by appending them to the vector: |
| 1798 for (const auto& attempt : stream_request_->connection_attempts()) | 1799 for (const auto& attempt : stream_request_->connection_attempts()) |
| 1799 connection_attempts_.push_back(attempt); | 1800 connection_attempts_.push_back(attempt); |
| 1800 } | 1801 } |
| 1801 | 1802 |
| 1802 } // namespace net | 1803 } // namespace net |
| OLD | NEW |