| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_response_info.h" | 5 #include "net/http/http_response_info.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/pickle.h" | 8 #include "base/pickle.h" |
| 9 #include "base/time.h" | 9 #include "base/time.h" |
| 10 #include "net/base/auth.h" | 10 #include "net/base/auth.h" |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 | 50 |
| 51 // This bit is set if the response was received via SPDY. | 51 // This bit is set if the response was received via SPDY. |
| 52 RESPONSE_INFO_WAS_SPDY = 1 << 13, | 52 RESPONSE_INFO_WAS_SPDY = 1 << 13, |
| 53 | 53 |
| 54 // This bit is set if the request has NPN negotiated. | 54 // This bit is set if the request has NPN negotiated. |
| 55 RESPONSE_INFO_WAS_NPN = 1 << 14, | 55 RESPONSE_INFO_WAS_NPN = 1 << 14, |
| 56 | 56 |
| 57 // This bit is set if the request was fetched via an explicit proxy. | 57 // This bit is set if the request was fetched via an explicit proxy. |
| 58 RESPONSE_INFO_WAS_PROXY = 1 << 15, | 58 RESPONSE_INFO_WAS_PROXY = 1 << 15, |
| 59 | 59 |
| 60 // This bit is set if the response info has an SSL connection status field. |
| 61 // This contains the ciphersuite used to fetch the resource as well as the |
| 62 // protocol version, compression method and whether SSLv3 fallback was used. |
| 63 RESPONSE_INFO_HAS_SSL_CONNECTION_STATUS = 1 << 16, |
| 64 |
| 60 // TODO(darin): Add other bits to indicate alternate request methods. | 65 // TODO(darin): Add other bits to indicate alternate request methods. |
| 61 // For now, we don't support storing those. | 66 // For now, we don't support storing those. |
| 62 }; | 67 }; |
| 63 | 68 |
| 64 HttpResponseInfo::HttpResponseInfo() | 69 HttpResponseInfo::HttpResponseInfo() |
| 65 : was_cached(false), | 70 : was_cached(false), |
| 66 was_fetched_via_spdy(false), | 71 was_fetched_via_spdy(false), |
| 67 was_npn_negotiated(false), | 72 was_npn_negotiated(false), |
| 68 was_fetched_via_proxy(false) { | 73 was_fetched_via_proxy(false) { |
| 69 } | 74 } |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 return false; | 156 return false; |
| 152 ssl_info.cert_status = cert_status; | 157 ssl_info.cert_status = cert_status; |
| 153 } | 158 } |
| 154 if (flags & RESPONSE_INFO_HAS_SECURITY_BITS) { | 159 if (flags & RESPONSE_INFO_HAS_SECURITY_BITS) { |
| 155 int security_bits; | 160 int security_bits; |
| 156 if (!pickle.ReadInt(&iter, &security_bits)) | 161 if (!pickle.ReadInt(&iter, &security_bits)) |
| 157 return false; | 162 return false; |
| 158 ssl_info.security_bits = security_bits; | 163 ssl_info.security_bits = security_bits; |
| 159 } | 164 } |
| 160 | 165 |
| 166 if (flags & RESPONSE_INFO_HAS_SSL_CONNECTION_STATUS) { |
| 167 int connection_status; |
| 168 if (!pickle.ReadInt(&iter, &connection_status)) |
| 169 return false; |
| 170 ssl_info.connection_status = connection_status; |
| 171 } |
| 172 |
| 161 // read vary-data | 173 // read vary-data |
| 162 if (flags & RESPONSE_INFO_HAS_VARY_DATA) { | 174 if (flags & RESPONSE_INFO_HAS_VARY_DATA) { |
| 163 if (!vary_data.InitFromPickle(pickle, &iter)) | 175 if (!vary_data.InitFromPickle(pickle, &iter)) |
| 164 return false; | 176 return false; |
| 165 } | 177 } |
| 166 | 178 |
| 167 // Read socket_address. | 179 // Read socket_address. |
| 168 std::string socket_address_host; | 180 std::string socket_address_host; |
| 169 if (pickle.ReadString(&iter, &socket_address_host)) { | 181 if (pickle.ReadString(&iter, &socket_address_host)) { |
| 170 // If the host was written, we always expect the port to follow. | 182 // If the host was written, we always expect the port to follow. |
| (...skipping 20 matching lines...) Expand all Loading... |
| 191 | 203 |
| 192 void HttpResponseInfo::Persist(Pickle* pickle, | 204 void HttpResponseInfo::Persist(Pickle* pickle, |
| 193 bool skip_transient_headers, | 205 bool skip_transient_headers, |
| 194 bool response_truncated) const { | 206 bool response_truncated) const { |
| 195 int flags = RESPONSE_INFO_VERSION; | 207 int flags = RESPONSE_INFO_VERSION; |
| 196 if (ssl_info.is_valid()) { | 208 if (ssl_info.is_valid()) { |
| 197 flags |= RESPONSE_INFO_HAS_CERT; | 209 flags |= RESPONSE_INFO_HAS_CERT; |
| 198 flags |= RESPONSE_INFO_HAS_CERT_STATUS; | 210 flags |= RESPONSE_INFO_HAS_CERT_STATUS; |
| 199 if (ssl_info.security_bits != -1) | 211 if (ssl_info.security_bits != -1) |
| 200 flags |= RESPONSE_INFO_HAS_SECURITY_BITS; | 212 flags |= RESPONSE_INFO_HAS_SECURITY_BITS; |
| 201 // TODO(wtc): we should persist ssl_info.connection_status. | 213 if (ssl_info.connection_status != 0) |
| 214 flags |= RESPONSE_INFO_HAS_SSL_CONNECTION_STATUS; |
| 202 } | 215 } |
| 203 if (vary_data.is_valid()) | 216 if (vary_data.is_valid()) |
| 204 flags |= RESPONSE_INFO_HAS_VARY_DATA; | 217 flags |= RESPONSE_INFO_HAS_VARY_DATA; |
| 205 if (response_truncated) | 218 if (response_truncated) |
| 206 flags |= RESPONSE_INFO_TRUNCATED; | 219 flags |= RESPONSE_INFO_TRUNCATED; |
| 207 if (was_fetched_via_spdy) | 220 if (was_fetched_via_spdy) |
| 208 flags |= RESPONSE_INFO_WAS_SPDY; | 221 flags |= RESPONSE_INFO_WAS_SPDY; |
| 209 if (was_npn_negotiated) | 222 if (was_npn_negotiated) |
| 210 flags |= RESPONSE_INFO_WAS_NPN; | 223 flags |= RESPONSE_INFO_WAS_NPN; |
| 211 if (was_fetched_via_proxy) | 224 if (was_fetched_via_proxy) |
| (...skipping 15 matching lines...) Expand all Loading... |
| 227 net::HttpResponseHeaders::PERSIST_SANS_RANGES; | 240 net::HttpResponseHeaders::PERSIST_SANS_RANGES; |
| 228 } | 241 } |
| 229 | 242 |
| 230 headers->Persist(pickle, persist_options); | 243 headers->Persist(pickle, persist_options); |
| 231 | 244 |
| 232 if (ssl_info.is_valid()) { | 245 if (ssl_info.is_valid()) { |
| 233 ssl_info.cert->Persist(pickle); | 246 ssl_info.cert->Persist(pickle); |
| 234 pickle->WriteInt(ssl_info.cert_status); | 247 pickle->WriteInt(ssl_info.cert_status); |
| 235 if (ssl_info.security_bits != -1) | 248 if (ssl_info.security_bits != -1) |
| 236 pickle->WriteInt(ssl_info.security_bits); | 249 pickle->WriteInt(ssl_info.security_bits); |
| 250 if (ssl_info.connection_status != 0) |
| 251 pickle->WriteInt(ssl_info.connection_status); |
| 237 } | 252 } |
| 238 | 253 |
| 239 if (vary_data.is_valid()) | 254 if (vary_data.is_valid()) |
| 240 vary_data.Persist(pickle); | 255 vary_data.Persist(pickle); |
| 241 | 256 |
| 242 pickle->WriteString(socket_address.host()); | 257 pickle->WriteString(socket_address.host()); |
| 243 pickle->WriteUInt16(socket_address.port()); | 258 pickle->WriteUInt16(socket_address.port()); |
| 244 } | 259 } |
| 245 | 260 |
| 246 } // namespace net | 261 } // namespace net |
| OLD | NEW |