1c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. 2c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott// Use of this source code is governed by a BSD-style license that can be 3c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott// found in the LICENSE file. 4c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott 5c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott#ifndef NET_HTTP_HTTP_RESPONSE_INFO_H_ 6c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott#define NET_HTTP_HTTP_RESPONSE_INFO_H_ 73345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick#pragma once 8c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott 9c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott#include "base/time.h" 10dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen#include "net/base/host_port_pair.h" 112557749644f9d25af9721533322db19197c49b49Kristian Monsen#include "net/base/net_export.h" 12c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott#include "net/base/ssl_info.h" 13c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott#include "net/http/http_vary_data.h" 14c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott 15c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scottclass Pickle; 16c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott 17c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scottnamespace net { 18c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott 193345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrickclass AuthChallengeInfo; 203345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrickclass HttpResponseHeaders; 213345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrickclass IOBufferWithSize; 223345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrickclass SSLCertRequestInfo; 233345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick 242557749644f9d25af9721533322db19197c49b49Kristian Monsenclass NET_EXPORT HttpResponseInfo { 25c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott public: 26c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott HttpResponseInfo(); 273345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick HttpResponseInfo(const HttpResponseInfo& rhs); 28c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott ~HttpResponseInfo(); 293345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick HttpResponseInfo& operator=(const HttpResponseInfo& rhs); 303345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick // Even though we could get away with the copy ctor and default operator=, 313345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick // that would prevent us from doing a bunch of forward declaration. 32c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott 333f50c38dc070f4bb515c1b64450dae14f316474eKristian Monsen // Initializes from the representation stored in the given pickle. 343f50c38dc070f4bb515c1b64450dae14f316474eKristian Monsen bool InitFromPickle(const Pickle& pickle, bool* response_truncated); 353f50c38dc070f4bb515c1b64450dae14f316474eKristian Monsen 363f50c38dc070f4bb515c1b64450dae14f316474eKristian Monsen // Call this method to persist the response info. 373f50c38dc070f4bb515c1b64450dae14f316474eKristian Monsen void Persist(Pickle* pickle, 383f50c38dc070f4bb515c1b64450dae14f316474eKristian Monsen bool skip_transient_headers, 393f50c38dc070f4bb515c1b64450dae14f316474eKristian Monsen bool response_truncated) const; 403f50c38dc070f4bb515c1b64450dae14f316474eKristian Monsen 41c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott // The following is only defined if the request_time member is set. 42c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott // If this response was resurrected from cache, then this bool is set, and 43c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott // request_time may corresponds to a time "far" in the past. Note that 44c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott // stale content (perhaps un-cacheable) may be fetched from cache subject to 45c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott // the load flags specified on the request info. For example, this is done 46c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch // when a user presses the back button to re-render pages, or at startup, 47c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch // when reloading previously visited pages (without going over the network). 48c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott bool was_cached; 49c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott 50c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott // True if the request was fetched over a SPDY channel. 51c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott bool was_fetched_via_spdy; 52c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott 53c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch // True if the npn was negotiated for this request. 54c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch bool was_npn_negotiated; 55c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 56c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch // True if the request was fetched via an explicit proxy. The proxy could 57c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch // be any type of proxy, HTTP or SOCKS. Note, we do not know if a 58c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch // transparent proxy may have been involved. 59c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch bool was_fetched_via_proxy; 60c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 61dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen // Remote address of the socket which fetched this resource. 62dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen // 63dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen // NOTE: If the response was served from the cache (was_cached is true), 64dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen // the socket address will be set to the address that the content came from 65dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen // originally. This is true even if the response was re-validated using a 66dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen // different remote address, or if some of the content came from a byte-range 67dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen // request to a different address. 68dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen HostPortPair socket_address; 69dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen 70c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott // The time at which the request was made that resulted in this response. 71c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott // For cached responses, this is the last time the cache entry was validated. 72c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott base::Time request_time; 73c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott 74c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott // The time at which the response headers were received. For cached 75c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott // this is the last time the cache entry was validated. 76c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott base::Time response_time; 77c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott 78c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott // If the response headers indicate a 401 or 407 failure, then this structure 79c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott // will contain additional information about the authentication challenge. 80c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott scoped_refptr<AuthChallengeInfo> auth_challenge; 81c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott 82c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott // The SSL client certificate request info. 83c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott // TODO(wtc): does this really belong in HttpResponseInfo? I put it here 84c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott // because it is similar to |auth_challenge|, but unlike HTTP authentication 85c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott // challenge, client certificate request is not part of an HTTP response. 86c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott scoped_refptr<SSLCertRequestInfo> cert_request_info; 87c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott 88c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott // The SSL connection info (if HTTPS). 89c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott SSLInfo ssl_info; 90c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott 91c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott // The parsed response headers and status line. 92c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott scoped_refptr<HttpResponseHeaders> headers; 93c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott 94c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott // The "Vary" header data for this response. 95c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott HttpVaryData vary_data; 96c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott 97c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch // Any metadata asociated with this resource's cached data. 98c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch scoped_refptr<IOBufferWithSize> metadata; 99c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott}; 100c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott 101c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott} // namespace net 102c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott 103c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott#endif // NET_HTTP_HTTP_RESPONSE_INFO_H_ 104