| 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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 uint16 version_after, | 112 uint16 version_after, |
| 113 NetLog::LogLevel /* log_level */) { | 113 NetLog::LogLevel /* log_level */) { |
| 114 base::DictionaryValue* dict = new base::DictionaryValue(); | 114 base::DictionaryValue* dict = new base::DictionaryValue(); |
| 115 dict->SetString("host_and_port", GetHostAndPort(*url)); | 115 dict->SetString("host_and_port", GetHostAndPort(*url)); |
| 116 dict->SetInteger("net_error", net_error); | 116 dict->SetInteger("net_error", net_error); |
| 117 dict->SetInteger("version_before", version_before); | 117 dict->SetInteger("version_before", version_before); |
| 118 dict->SetInteger("version_after", version_after); | 118 dict->SetInteger("version_after", version_after); |
| 119 return dict; | 119 return dict; |
| 120 } | 120 } |
| 121 | 121 |
| 122 #if defined(SPDY_PROXY_AUTH_ORIGIN) | |
| 123 // Returns true if |response_headers| contains the data reduction proxy Via | |
| 124 // header value. | |
| 125 bool IsChromeProxyResponse(const net::HttpResponseHeaders* response_headers) { | |
| 126 if (!response_headers) { | |
| 127 return false; | |
| 128 } | |
| 129 const char kDataReductionProxyViaValue[] = "1.1 Chrome Compression Proxy"; | |
| 130 size_t value_len = strlen(kDataReductionProxyViaValue); | |
| 131 void* iter = NULL; | |
| 132 std::string temp; | |
| 133 while (response_headers->EnumerateHeader(&iter, "Via", &temp)) { | |
| 134 std::string::const_iterator it = | |
| 135 std::search(temp.begin(), temp.end(), | |
| 136 kDataReductionProxyViaValue, | |
| 137 kDataReductionProxyViaValue + value_len, | |
| 138 base::CaseInsensitiveCompareASCII<char>()); | |
| 139 if (it != temp.end()) | |
| 140 return true; | |
| 141 } | |
| 142 return false; | |
| 143 } | |
| 144 #endif | |
| 145 | |
| 146 } // namespace | 122 } // namespace |
| 147 | 123 |
| 148 //----------------------------------------------------------------------------- | 124 //----------------------------------------------------------------------------- |
| 149 | 125 |
| 150 HttpNetworkTransaction::HttpNetworkTransaction(RequestPriority priority, | 126 HttpNetworkTransaction::HttpNetworkTransaction(RequestPriority priority, |
| 151 HttpNetworkSession* session) | 127 HttpNetworkSession* session) |
| 152 : pending_auth_target_(HttpAuth::AUTH_NONE), | 128 : pending_auth_target_(HttpAuth::AUTH_NONE), |
| 153 io_callback_(base::Bind(&HttpNetworkTransaction::OnIOComplete, | 129 io_callback_(base::Bind(&HttpNetworkTransaction::OnIOComplete, |
| 154 base::Unretained(this))), | 130 base::Unretained(this))), |
| 155 session_(session), | 131 session_(session), |
| (...skipping 880 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1036 proxy_info_.proxy_server().isDataReductionProxy(); | 1012 proxy_info_.proxy_server().isDataReductionProxy(); |
| 1037 bool chrome_fallback_proxy_used = false; | 1013 bool chrome_fallback_proxy_used = false; |
| 1038 #if defined(DATA_REDUCTION_FALLBACK_HOST) | 1014 #if defined(DATA_REDUCTION_FALLBACK_HOST) |
| 1039 if (!chrome_proxy_used) { | 1015 if (!chrome_proxy_used) { |
| 1040 chrome_fallback_proxy_used = | 1016 chrome_fallback_proxy_used = |
| 1041 proxy_info_.proxy_server().isDataReductionProxyFallback(); | 1017 proxy_info_.proxy_server().isDataReductionProxyFallback(); |
| 1042 } | 1018 } |
| 1043 #endif | 1019 #endif |
| 1044 | 1020 |
| 1045 if (chrome_proxy_used || chrome_fallback_proxy_used) { | 1021 if (chrome_proxy_used || chrome_fallback_proxy_used) { |
| 1046 if (!IsChromeProxyResponse(response_.headers.get())) { | 1022 if (!response_.headers->IsChromeProxyResponse()) { |
| 1047 proxy_bypass_event = ProxyService::MISSING_VIA_HEADER; | 1023 proxy_bypass_event = ProxyService::MISSING_VIA_HEADER; |
| 1048 } else if (response_.headers->GetChromeProxyInfo(&chrome_proxy_info)) { | 1024 } else if (response_.headers->GetChromeProxyInfo(&chrome_proxy_info)) { |
| 1049 if (chrome_proxy_info.bypass_duration < TimeDelta::FromMinutes(30)) | 1025 if (chrome_proxy_info.bypass_duration < TimeDelta::FromMinutes(30)) |
| 1050 proxy_bypass_event = ProxyService::SHORT_BYPASS; | 1026 proxy_bypass_event = ProxyService::SHORT_BYPASS; |
| 1051 else | 1027 else |
| 1052 proxy_bypass_event = ProxyService::LONG_BYPASS; | 1028 proxy_bypass_event = ProxyService::LONG_BYPASS; |
| 1053 } else { | 1029 } else { |
| 1054 // Additionally, fallback if a 500, 502 or 503 is returned via the data | 1030 // Additionally, fallback if a 500, 502 or 503 is returned via the data |
| 1055 // reduction proxy. This is conservative, as the 500, 502 or 503 might | 1031 // reduction proxy. This is conservative, as the 500, 502 or 503 might |
| 1056 // have been generated by the origin, and not the proxy. | 1032 // have been generated by the origin, and not the proxy. |
| (...skipping 590 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1647 description = base::StringPrintf("Unknown state 0x%08X (%u)", state, | 1623 description = base::StringPrintf("Unknown state 0x%08X (%u)", state, |
| 1648 state); | 1624 state); |
| 1649 break; | 1625 break; |
| 1650 } | 1626 } |
| 1651 return description; | 1627 return description; |
| 1652 } | 1628 } |
| 1653 | 1629 |
| 1654 #undef STATE_CASE | 1630 #undef STATE_CASE |
| 1655 | 1631 |
| 1656 } // namespace net | 1632 } // namespace net |
| OLD | NEW |