Home | History | Annotate | Download | only in public
      1 /*
      2  * Copyright (C) 2009 Google Inc. All rights reserved.
      3  *
      4  * Redistribution and use in source and binary forms, with or without
      5  * modification, are permitted provided that the following conditions are
      6  * met:
      7  *
      8  *     * Redistributions of source code must retain the above copyright
      9  * notice, this list of conditions and the following disclaimer.
     10  *     * Redistributions in binary form must reproduce the above
     11  * copyright notice, this list of conditions and the following disclaimer
     12  * in the documentation and/or other materials provided with the
     13  * distribution.
     14  *     * Neither the name of Google Inc. nor the names of its
     15  * contributors may be used to endorse or promote products derived from
     16  * this software without specific prior written permission.
     17  *
     18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     19  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     20  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
     21  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
     22  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
     23  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
     24  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     25  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     26  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     27  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
     28  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     29  */
     30 
     31 #ifndef WebURLResponse_h
     32 #define WebURLResponse_h
     33 
     34 #include "WebCommon.h"
     35 #include "WebPrivateOwnPtr.h"
     36 
     37 #if defined(WEBKIT_IMPLEMENTATION)
     38 namespace WebCore { class ResourceResponse; }
     39 #endif
     40 
     41 namespace WebKit {
     42 
     43 class WebCString;
     44 class WebHTTPHeaderVisitor;
     45 class WebHTTPLoadInfo;
     46 class WebString;
     47 class WebURL;
     48 class WebURLLoadTiming;
     49 class WebURLResponsePrivate;
     50 
     51 class WebURLResponse {
     52 public:
     53     ~WebURLResponse() { reset(); }
     54 
     55     WebURLResponse() : m_private(0) { }
     56     WebURLResponse(const WebURLResponse& r) : m_private(0) { assign(r); }
     57     WebURLResponse& operator=(const WebURLResponse& r)
     58     {
     59         assign(r);
     60         return *this;
     61     }
     62 
     63     explicit WebURLResponse(const WebURL& url) : m_private(0)
     64     {
     65         initialize();
     66         setURL(url);
     67     }
     68 
     69     WEBKIT_API void initialize();
     70     WEBKIT_API void reset();
     71     WEBKIT_API void assign(const WebURLResponse&);
     72 
     73     WEBKIT_API bool isNull() const;
     74 
     75     WEBKIT_API WebURL url() const;
     76     WEBKIT_API void setURL(const WebURL&);
     77 
     78     WEBKIT_API unsigned connectionID() const;
     79     WEBKIT_API void setConnectionID(unsigned);
     80 
     81     WEBKIT_API bool connectionReused() const;
     82     WEBKIT_API void setConnectionReused(bool);
     83 
     84     WEBKIT_API WebURLLoadTiming loadTiming();
     85     WEBKIT_API void setLoadTiming(const WebURLLoadTiming&);
     86 
     87     WEBKIT_API WebHTTPLoadInfo httpLoadInfo();
     88     WEBKIT_API void setHTTPLoadInfo(const WebHTTPLoadInfo&);
     89 
     90     WEBKIT_API double responseTime() const;
     91     WEBKIT_API void setResponseTime(double);
     92 
     93     WEBKIT_API WebString mimeType() const;
     94     WEBKIT_API void setMIMEType(const WebString&);
     95 
     96     WEBKIT_API long long expectedContentLength() const;
     97     WEBKIT_API void setExpectedContentLength(long long);
     98 
     99     WEBKIT_API WebString textEncodingName() const;
    100     WEBKIT_API void setTextEncodingName(const WebString&);
    101 
    102     WEBKIT_API WebString suggestedFileName() const;
    103     WEBKIT_API void setSuggestedFileName(const WebString&);
    104 
    105     WEBKIT_API int httpStatusCode() const;
    106     WEBKIT_API void setHTTPStatusCode(int);
    107 
    108     WEBKIT_API WebString httpStatusText() const;
    109     WEBKIT_API void setHTTPStatusText(const WebString&);
    110 
    111     WEBKIT_API WebString httpHeaderField(const WebString& name) const;
    112     WEBKIT_API void setHTTPHeaderField(const WebString& name, const WebString& value);
    113     WEBKIT_API void addHTTPHeaderField(const WebString& name, const WebString& value);
    114     WEBKIT_API void clearHTTPHeaderField(const WebString& name);
    115     WEBKIT_API void visitHTTPHeaderFields(WebHTTPHeaderVisitor*) const;
    116 
    117     WEBKIT_API double lastModifiedDate() const;
    118     WEBKIT_API void setLastModifiedDate(double);
    119 
    120     WEBKIT_API long long appCacheID() const;
    121     WEBKIT_API void setAppCacheID(long long);
    122 
    123     WEBKIT_API WebURL appCacheManifestURL() const;
    124     WEBKIT_API void setAppCacheManifestURL(const WebURL&);
    125 
    126     // A consumer controlled value intended to be used to record opaque
    127     // security info related to this request.
    128     WEBKIT_API WebCString securityInfo() const;
    129     WEBKIT_API void setSecurityInfo(const WebCString&);
    130 
    131 #if defined(WEBKIT_IMPLEMENTATION)
    132     WebCore::ResourceResponse& toMutableResourceResponse();
    133     const WebCore::ResourceResponse& toResourceResponse() const;
    134 #endif
    135 
    136     // Flag whether this request was served from the disk cache entry.
    137     WEBKIT_API bool wasCached() const;
    138     WEBKIT_API void setWasCached(bool);
    139 
    140     // Flag whether this request was loaded via the SPDY protocol or not.
    141     // SPDY is an experimental web protocol, see http://dev.chromium.org/spdy
    142     WEBKIT_API bool wasFetchedViaSPDY() const;
    143     WEBKIT_API void setWasFetchedViaSPDY(bool);
    144 
    145     // Flag whether this request was loaded after the TLS/Next-Protocol-Negotiation was used.
    146     // This is related to SPDY.
    147     WEBKIT_API bool wasNpnNegotiated() const;
    148     WEBKIT_API void setWasNpnNegotiated(bool);
    149 
    150     // Flag whether this request was made when "Alternate-Protocol: xxx"
    151     // is present in server's response.
    152     WEBKIT_API bool wasAlternateProtocolAvailable() const;
    153     WEBKIT_API void setWasAlternateProtocolAvailable(bool);
    154 
    155     // Flag whether this request was loaded via an explicit proxy (HTTP, SOCKS, etc).
    156     WEBKIT_API bool wasFetchedViaProxy() const;
    157     WEBKIT_API void setWasFetchedViaProxy(bool);
    158 
    159     // Flag whether this request is part of a multipart response.
    160     WEBKIT_API bool isMultipartPayload() const;
    161     WEBKIT_API void setIsMultipartPayload(bool);
    162 
    163     // This indicates the location of a downloaded response if the
    164     // WebURLRequest had the downloadToFile flag set to true.  This file path
    165     // remains valid for the lifetime of the WebURLLoader used to create it.
    166     WEBKIT_API WebString downloadFilePath() const;
    167     WEBKIT_API void setDownloadFilePath(const WebString&);
    168 
    169     // Remote IP address of the socket which fetched this resource.
    170     WEBKIT_API WebString remoteIPAddress() const;
    171     WEBKIT_API void setRemoteIPAddress(const WebString&);
    172 
    173     // Remote port number of the socket which fetched this resource.
    174     WEBKIT_API unsigned short remotePort() const;
    175     WEBKIT_API void setRemotePort(unsigned short);
    176 
    177 protected:
    178     void assign(WebURLResponsePrivate*);
    179 
    180 private:
    181     WebURLResponsePrivate* m_private;
    182 };
    183 
    184 } // namespace WebKit
    185 
    186 #endif
    187