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