Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(106)

Side by Side Diff: net/http/http_response_info.cc

Issue 13609002: fix a problem that android cannot download files with basic authentication (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: nits Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/http/http_response_info.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 // This contains the ciphersuite used to fetch the resource as well as the 77 // This contains the ciphersuite used to fetch the resource as well as the
78 // protocol version, compression method and whether SSLv3 fallback was used. 78 // protocol version, compression method and whether SSLv3 fallback was used.
79 RESPONSE_INFO_HAS_SSL_CONNECTION_STATUS = 1 << 16, 79 RESPONSE_INFO_HAS_SSL_CONNECTION_STATUS = 1 << 16,
80 80
81 // This bit is set if the response info has protocol version. 81 // This bit is set if the response info has protocol version.
82 RESPONSE_INFO_HAS_NPN_NEGOTIATED_PROTOCOL = 1 << 17, 82 RESPONSE_INFO_HAS_NPN_NEGOTIATED_PROTOCOL = 1 << 17,
83 83
84 // This bit is set if the response info has connection info. 84 // This bit is set if the response info has connection info.
85 RESPONSE_INFO_HAS_CONNECTION_INFO = 1 << 18, 85 RESPONSE_INFO_HAS_CONNECTION_INFO = 1 << 18,
86 86
87 // This bit is set if the request has http authentication.
88 RESPONSE_INFO_USE_HTTP_AUTHENTICATION = 1 << 19,
89
87 // TODO(darin): Add other bits to indicate alternate request methods. 90 // TODO(darin): Add other bits to indicate alternate request methods.
88 // For now, we don't support storing those. 91 // For now, we don't support storing those.
89 }; 92 };
90 93
91 HttpResponseInfo::HttpResponseInfo() 94 HttpResponseInfo::HttpResponseInfo()
92 : was_cached(false), 95 : was_cached(false),
93 server_data_unavailable(false), 96 server_data_unavailable(false),
94 was_fetched_via_spdy(false), 97 was_fetched_via_spdy(false),
95 was_npn_negotiated(false), 98 was_npn_negotiated(false),
96 was_fetched_via_proxy(false), 99 was_fetched_via_proxy(false),
100 did_use_http_auth(false),
97 connection_info(CONNECTION_INFO_UNKNOWN) { 101 connection_info(CONNECTION_INFO_UNKNOWN) {
98 } 102 }
99 103
100 HttpResponseInfo::HttpResponseInfo(const HttpResponseInfo& rhs) 104 HttpResponseInfo::HttpResponseInfo(const HttpResponseInfo& rhs)
101 : was_cached(rhs.was_cached), 105 : was_cached(rhs.was_cached),
102 server_data_unavailable(rhs.server_data_unavailable), 106 server_data_unavailable(rhs.server_data_unavailable),
103 was_fetched_via_spdy(rhs.was_fetched_via_spdy), 107 was_fetched_via_spdy(rhs.was_fetched_via_spdy),
104 was_npn_negotiated(rhs.was_npn_negotiated), 108 was_npn_negotiated(rhs.was_npn_negotiated),
105 was_fetched_via_proxy(rhs.was_fetched_via_proxy), 109 was_fetched_via_proxy(rhs.was_fetched_via_proxy),
110 did_use_http_auth(rhs.did_use_http_auth),
106 socket_address(rhs.socket_address), 111 socket_address(rhs.socket_address),
107 npn_negotiated_protocol(rhs.npn_negotiated_protocol), 112 npn_negotiated_protocol(rhs.npn_negotiated_protocol),
108 connection_info(rhs.connection_info), 113 connection_info(rhs.connection_info),
109 request_time(rhs.request_time), 114 request_time(rhs.request_time),
110 response_time(rhs.response_time), 115 response_time(rhs.response_time),
111 auth_challenge(rhs.auth_challenge), 116 auth_challenge(rhs.auth_challenge),
112 cert_request_info(rhs.cert_request_info), 117 cert_request_info(rhs.cert_request_info),
113 ssl_info(rhs.ssl_info), 118 ssl_info(rhs.ssl_info),
114 headers(rhs.headers), 119 headers(rhs.headers),
115 vary_data(rhs.vary_data), 120 vary_data(rhs.vary_data),
116 metadata(rhs.metadata) { 121 metadata(rhs.metadata) {
117 } 122 }
118 123
119 HttpResponseInfo::~HttpResponseInfo() { 124 HttpResponseInfo::~HttpResponseInfo() {
120 } 125 }
121 126
122 HttpResponseInfo& HttpResponseInfo::operator=(const HttpResponseInfo& rhs) { 127 HttpResponseInfo& HttpResponseInfo::operator=(const HttpResponseInfo& rhs) {
123 was_cached = rhs.was_cached; 128 was_cached = rhs.was_cached;
124 server_data_unavailable = rhs.server_data_unavailable; 129 server_data_unavailable = rhs.server_data_unavailable;
125 was_fetched_via_spdy = rhs.was_fetched_via_spdy; 130 was_fetched_via_spdy = rhs.was_fetched_via_spdy;
126 was_npn_negotiated = rhs.was_npn_negotiated; 131 was_npn_negotiated = rhs.was_npn_negotiated;
127 was_fetched_via_proxy = rhs.was_fetched_via_proxy; 132 was_fetched_via_proxy = rhs.was_fetched_via_proxy;
133 did_use_http_auth = rhs.did_use_http_auth;
128 socket_address = rhs.socket_address; 134 socket_address = rhs.socket_address;
129 npn_negotiated_protocol = rhs.npn_negotiated_protocol; 135 npn_negotiated_protocol = rhs.npn_negotiated_protocol;
130 request_time = rhs.request_time; 136 request_time = rhs.request_time;
131 response_time = rhs.response_time; 137 response_time = rhs.response_time;
132 auth_challenge = rhs.auth_challenge; 138 auth_challenge = rhs.auth_challenge;
133 cert_request_info = rhs.cert_request_info; 139 cert_request_info = rhs.cert_request_info;
134 ssl_info = rhs.ssl_info; 140 ssl_info = rhs.ssl_info;
135 headers = rhs.headers; 141 headers = rhs.headers;
136 vary_data = rhs.vary_data; 142 vary_data = rhs.vary_data;
137 metadata = rhs.metadata; 143 metadata = rhs.metadata;
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 } 242 }
237 243
238 was_fetched_via_spdy = (flags & RESPONSE_INFO_WAS_SPDY) != 0; 244 was_fetched_via_spdy = (flags & RESPONSE_INFO_WAS_SPDY) != 0;
239 245
240 was_npn_negotiated = (flags & RESPONSE_INFO_WAS_NPN) != 0; 246 was_npn_negotiated = (flags & RESPONSE_INFO_WAS_NPN) != 0;
241 247
242 was_fetched_via_proxy = (flags & RESPONSE_INFO_WAS_PROXY) != 0; 248 was_fetched_via_proxy = (flags & RESPONSE_INFO_WAS_PROXY) != 0;
243 249
244 *response_truncated = (flags & RESPONSE_INFO_TRUNCATED) != 0; 250 *response_truncated = (flags & RESPONSE_INFO_TRUNCATED) != 0;
245 251
252 did_use_http_auth = (flags & RESPONSE_INFO_USE_HTTP_AUTHENTICATION) != 0;
253
246 return true; 254 return true;
247 } 255 }
248 256
249 void HttpResponseInfo::Persist(Pickle* pickle, 257 void HttpResponseInfo::Persist(Pickle* pickle,
250 bool skip_transient_headers, 258 bool skip_transient_headers,
251 bool response_truncated) const { 259 bool response_truncated) const {
252 int flags = RESPONSE_INFO_VERSION; 260 int flags = RESPONSE_INFO_VERSION;
253 if (ssl_info.is_valid()) { 261 if (ssl_info.is_valid()) {
254 flags |= RESPONSE_INFO_HAS_CERT; 262 flags |= RESPONSE_INFO_HAS_CERT;
255 flags |= RESPONSE_INFO_HAS_CERT_STATUS; 263 flags |= RESPONSE_INFO_HAS_CERT_STATUS;
256 if (ssl_info.security_bits != -1) 264 if (ssl_info.security_bits != -1)
257 flags |= RESPONSE_INFO_HAS_SECURITY_BITS; 265 flags |= RESPONSE_INFO_HAS_SECURITY_BITS;
258 if (ssl_info.connection_status != 0) 266 if (ssl_info.connection_status != 0)
259 flags |= RESPONSE_INFO_HAS_SSL_CONNECTION_STATUS; 267 flags |= RESPONSE_INFO_HAS_SSL_CONNECTION_STATUS;
260 } 268 }
261 if (vary_data.is_valid()) 269 if (vary_data.is_valid())
262 flags |= RESPONSE_INFO_HAS_VARY_DATA; 270 flags |= RESPONSE_INFO_HAS_VARY_DATA;
263 if (response_truncated) 271 if (response_truncated)
264 flags |= RESPONSE_INFO_TRUNCATED; 272 flags |= RESPONSE_INFO_TRUNCATED;
265 if (was_fetched_via_spdy) 273 if (was_fetched_via_spdy)
266 flags |= RESPONSE_INFO_WAS_SPDY; 274 flags |= RESPONSE_INFO_WAS_SPDY;
267 if (was_npn_negotiated) { 275 if (was_npn_negotiated) {
268 flags |= RESPONSE_INFO_WAS_NPN; 276 flags |= RESPONSE_INFO_WAS_NPN;
269 flags |= RESPONSE_INFO_HAS_NPN_NEGOTIATED_PROTOCOL; 277 flags |= RESPONSE_INFO_HAS_NPN_NEGOTIATED_PROTOCOL;
270 } 278 }
271 if (was_fetched_via_proxy) 279 if (was_fetched_via_proxy)
272 flags |= RESPONSE_INFO_WAS_PROXY; 280 flags |= RESPONSE_INFO_WAS_PROXY;
273 if (connection_info != CONNECTION_INFO_UNKNOWN) 281 if (connection_info != CONNECTION_INFO_UNKNOWN)
274 flags |= RESPONSE_INFO_HAS_CONNECTION_INFO; 282 flags |= RESPONSE_INFO_HAS_CONNECTION_INFO;
283 if (did_use_http_auth)
284 flags |= RESPONSE_INFO_USE_HTTP_AUTHENTICATION;
275 285
276 pickle->WriteInt(flags); 286 pickle->WriteInt(flags);
277 pickle->WriteInt64(request_time.ToInternalValue()); 287 pickle->WriteInt64(request_time.ToInternalValue());
278 pickle->WriteInt64(response_time.ToInternalValue()); 288 pickle->WriteInt64(response_time.ToInternalValue());
279 289
280 net::HttpResponseHeaders::PersistOptions persist_options = 290 net::HttpResponseHeaders::PersistOptions persist_options =
281 net::HttpResponseHeaders::PERSIST_RAW; 291 net::HttpResponseHeaders::PERSIST_RAW;
282 292
283 if (skip_transient_headers) { 293 if (skip_transient_headers) {
284 persist_options = 294 persist_options =
(...skipping 23 matching lines...) Expand all
308 pickle->WriteUInt16(socket_address.port()); 318 pickle->WriteUInt16(socket_address.port());
309 319
310 if (was_npn_negotiated) 320 if (was_npn_negotiated)
311 pickle->WriteString(npn_negotiated_protocol); 321 pickle->WriteString(npn_negotiated_protocol);
312 322
313 if (connection_info != CONNECTION_INFO_UNKNOWN) 323 if (connection_info != CONNECTION_INFO_UNKNOWN)
314 pickle->WriteInt(static_cast<int>(connection_info)); 324 pickle->WriteInt(static_cast<int>(connection_info));
315 } 325 }
316 326
317 } // namespace net 327 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_response_info.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698