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 
     36 #if defined(WEBKIT_IMPLEMENTATION)
     37 namespace WebCore { class ResourceResponse; }
     38 #endif
     39 
     40 namespace WebKit {
     41 
     42 class WebCString;
     43 class WebHTTPHeaderVisitor;
     44 class WebString;
     45 class WebURL;
     46 class WebURLResponsePrivate;
     47 
     48 class WebURLResponse {
     49 public:
     50     ~WebURLResponse() { reset(); }
     51 
     52     WebURLResponse() : m_private(0) { }
     53     WebURLResponse(const WebURLResponse& r) : m_private(0) { assign(r); }
     54     WebURLResponse& operator=(const WebURLResponse& r)
     55     {
     56         assign(r);
     57         return *this;
     58     }
     59 
     60     explicit WebURLResponse(const WebURL& url) : m_private(0)
     61     {
     62         initialize();
     63         setURL(url);
     64     }
     65 
     66     WEBKIT_API void initialize();
     67     WEBKIT_API void reset();
     68     WEBKIT_API void assign(const WebURLResponse&);
     69 
     70     WEBKIT_API bool isNull() const;
     71 
     72     WEBKIT_API WebURL url() const;
     73     WEBKIT_API void setURL(const WebURL&);
     74 
     75     WEBKIT_API WebString mimeType() const;
     76     WEBKIT_API void setMIMEType(const WebString&);
     77 
     78     WEBKIT_API long long expectedContentLength() const;
     79     WEBKIT_API void setExpectedContentLength(long long);
     80 
     81     WEBKIT_API WebString textEncodingName() const;
     82     WEBKIT_API void setTextEncodingName(const WebString&);
     83 
     84     WEBKIT_API WebString suggestedFileName() const;
     85     WEBKIT_API void setSuggestedFileName(const WebString&);
     86 
     87     WEBKIT_API int httpStatusCode() const;
     88     WEBKIT_API void setHTTPStatusCode(int);
     89 
     90     WEBKIT_API WebString httpStatusText() const;
     91     WEBKIT_API void setHTTPStatusText(const WebString&);
     92 
     93     WEBKIT_API WebString httpHeaderField(const WebString& name) const;
     94     WEBKIT_API void setHTTPHeaderField(const WebString& name, const WebString& value);
     95     WEBKIT_API void addHTTPHeaderField(const WebString& name, const WebString& value);
     96     WEBKIT_API void clearHTTPHeaderField(const WebString& name);
     97     WEBKIT_API void visitHTTPHeaderFields(WebHTTPHeaderVisitor*) const;
     98 
     99     WEBKIT_API double lastModifiedDate() const;
    100     WEBKIT_API void setLastModifiedDate(double);
    101 
    102     WEBKIT_API bool isContentFiltered() const;
    103     WEBKIT_API void setIsContentFiltered(bool);
    104 
    105     WEBKIT_API long long appCacheID() const;
    106     WEBKIT_API void setAppCacheID(long long);
    107 
    108     WEBKIT_API WebURL appCacheManifestURL() const;
    109     WEBKIT_API void setAppCacheManifestURL(const WebURL&);
    110 
    111     // A consumer controlled value intended to be used to record opaque
    112     // security info related to this request.
    113     WEBKIT_API WebCString securityInfo() const;
    114     WEBKIT_API void setSecurityInfo(const WebCString&);
    115 
    116 #if defined(WEBKIT_IMPLEMENTATION)
    117     WebCore::ResourceResponse& toMutableResourceResponse();
    118     const WebCore::ResourceResponse& toResourceResponse() const;
    119 #endif
    120 
    121     // Flag whether this request was loaded via the SPDY protocol or not.
    122     // SPDY is an experimental web protocol, see http://dev.chromium.org/spdy
    123     WEBKIT_API bool wasFetchedViaSPDY() const;
    124     WEBKIT_API void setWasFetchedViaSPDY(bool);
    125 
    126 protected:
    127     void assign(WebURLResponsePrivate*);
    128 
    129 private:
    130     WebURLResponsePrivate* m_private;
    131 };
    132 
    133 } // namespace WebKit
    134 
    135 #endif
    136