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