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