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