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 INSIDE_BLINK 38namespace WebCore { class ResourceResponse; } 39#endif 40 41namespace blink { 42 43class WebCString; 44class WebHTTPHeaderVisitor; 45class WebHTTPLoadInfo; 46class WebString; 47class WebURL; 48class WebURLLoadTiming; 49class WebURLResponsePrivate; 50 51class WebURLResponse { 52public: 53 enum HTTPVersion { Unknown, HTTP_0_9, HTTP_1_0, HTTP_1_1 }; 54 55 class ExtraData { 56 public: 57 virtual ~ExtraData() { } 58 }; 59 60 ~WebURLResponse() { reset(); } 61 62 WebURLResponse() : m_private(0) { } 63 WebURLResponse(const WebURLResponse& r) : m_private(0) { assign(r); } 64 WebURLResponse& operator=(const WebURLResponse& r) 65 { 66 assign(r); 67 return *this; 68 } 69 70 explicit WebURLResponse(const WebURL& url) : m_private(0) 71 { 72 initialize(); 73 setURL(url); 74 } 75 76 BLINK_PLATFORM_EXPORT void initialize(); 77 BLINK_PLATFORM_EXPORT void reset(); 78 BLINK_PLATFORM_EXPORT void assign(const WebURLResponse&); 79 80 BLINK_PLATFORM_EXPORT bool isNull() const; 81 82 BLINK_PLATFORM_EXPORT WebURL url() const; 83 BLINK_PLATFORM_EXPORT void setURL(const WebURL&); 84 85 BLINK_PLATFORM_EXPORT unsigned connectionID() const; 86 BLINK_PLATFORM_EXPORT void setConnectionID(unsigned); 87 88 BLINK_PLATFORM_EXPORT bool connectionReused() const; 89 BLINK_PLATFORM_EXPORT void setConnectionReused(bool); 90 91 BLINK_PLATFORM_EXPORT WebURLLoadTiming loadTiming(); 92 BLINK_PLATFORM_EXPORT void setLoadTiming(const WebURLLoadTiming&); 93 94 BLINK_PLATFORM_EXPORT WebHTTPLoadInfo httpLoadInfo(); 95 BLINK_PLATFORM_EXPORT void setHTTPLoadInfo(const WebHTTPLoadInfo&); 96 97 BLINK_PLATFORM_EXPORT double responseTime() const; 98 BLINK_PLATFORM_EXPORT void setResponseTime(double); 99 100 BLINK_PLATFORM_EXPORT WebString mimeType() const; 101 BLINK_PLATFORM_EXPORT void setMIMEType(const WebString&); 102 103 BLINK_PLATFORM_EXPORT long long expectedContentLength() const; 104 BLINK_PLATFORM_EXPORT void setExpectedContentLength(long long); 105 106 BLINK_PLATFORM_EXPORT WebString textEncodingName() const; 107 BLINK_PLATFORM_EXPORT void setTextEncodingName(const WebString&); 108 109 BLINK_PLATFORM_EXPORT WebString suggestedFileName() const; 110 BLINK_PLATFORM_EXPORT void setSuggestedFileName(const WebString&); 111 112 BLINK_PLATFORM_EXPORT HTTPVersion httpVersion() const; 113 BLINK_PLATFORM_EXPORT void setHTTPVersion(HTTPVersion); 114 115 BLINK_PLATFORM_EXPORT int httpStatusCode() const; 116 BLINK_PLATFORM_EXPORT void setHTTPStatusCode(int); 117 118 BLINK_PLATFORM_EXPORT WebString httpStatusText() const; 119 BLINK_PLATFORM_EXPORT void setHTTPStatusText(const WebString&); 120 121 BLINK_PLATFORM_EXPORT WebString httpHeaderField(const WebString& name) const; 122 BLINK_PLATFORM_EXPORT void setHTTPHeaderField(const WebString& name, const WebString& value); 123 BLINK_PLATFORM_EXPORT void addHTTPHeaderField(const WebString& name, const WebString& value); 124 BLINK_PLATFORM_EXPORT void clearHTTPHeaderField(const WebString& name); 125 BLINK_PLATFORM_EXPORT void visitHTTPHeaderFields(WebHTTPHeaderVisitor*) const; 126 127 BLINK_PLATFORM_EXPORT double lastModifiedDate() const; 128 BLINK_PLATFORM_EXPORT void setLastModifiedDate(double); 129 130 BLINK_PLATFORM_EXPORT long long appCacheID() const; 131 BLINK_PLATFORM_EXPORT void setAppCacheID(long long); 132 133 BLINK_PLATFORM_EXPORT WebURL appCacheManifestURL() const; 134 BLINK_PLATFORM_EXPORT void setAppCacheManifestURL(const WebURL&); 135 136 // A consumer controlled value intended to be used to record opaque 137 // security info related to this request. 138 BLINK_PLATFORM_EXPORT WebCString securityInfo() const; 139 BLINK_PLATFORM_EXPORT void setSecurityInfo(const WebCString&); 140 141#if INSIDE_BLINK 142 BLINK_PLATFORM_EXPORT WebCore::ResourceResponse& toMutableResourceResponse(); 143 BLINK_PLATFORM_EXPORT const WebCore::ResourceResponse& toResourceResponse() const; 144#endif 145 146 // Flag whether this request was served from the disk cache entry. 147 BLINK_PLATFORM_EXPORT bool wasCached() const; 148 BLINK_PLATFORM_EXPORT void setWasCached(bool); 149 150 // Flag whether this request was loaded via the SPDY protocol or not. 151 // SPDY is an experimental web protocol, see http://dev.chromium.org/spdy 152 BLINK_PLATFORM_EXPORT bool wasFetchedViaSPDY() const; 153 BLINK_PLATFORM_EXPORT void setWasFetchedViaSPDY(bool); 154 155 // Flag whether this request was loaded after the TLS/Next-Protocol-Negotiation was used. 156 // This is related to SPDY. 157 BLINK_PLATFORM_EXPORT bool wasNpnNegotiated() const; 158 BLINK_PLATFORM_EXPORT void setWasNpnNegotiated(bool); 159 160 // Flag whether this request was made when "Alternate-Protocol: xxx" 161 // is present in server's response. 162 BLINK_PLATFORM_EXPORT bool wasAlternateProtocolAvailable() const; 163 BLINK_PLATFORM_EXPORT void setWasAlternateProtocolAvailable(bool); 164 165 // Flag whether this request was loaded via an explicit proxy (HTTP, SOCKS, etc). 166 BLINK_PLATFORM_EXPORT bool wasFetchedViaProxy() const; 167 BLINK_PLATFORM_EXPORT void setWasFetchedViaProxy(bool); 168 169 // Flag whether this request is part of a multipart response. 170 BLINK_PLATFORM_EXPORT bool isMultipartPayload() const; 171 BLINK_PLATFORM_EXPORT void setIsMultipartPayload(bool); 172 173 // This indicates the location of a downloaded response if the 174 // WebURLRequest had the downloadToFile flag set to true. This file path 175 // remains valid for the lifetime of the WebURLLoader used to create it. 176 BLINK_PLATFORM_EXPORT WebString downloadFilePath() const; 177 BLINK_PLATFORM_EXPORT void setDownloadFilePath(const WebString&); 178 179 // Remote IP address of the socket which fetched this resource. 180 BLINK_PLATFORM_EXPORT WebString remoteIPAddress() const; 181 BLINK_PLATFORM_EXPORT void setRemoteIPAddress(const WebString&); 182 183 // Remote port number of the socket which fetched this resource. 184 BLINK_PLATFORM_EXPORT unsigned short remotePort() const; 185 BLINK_PLATFORM_EXPORT void setRemotePort(unsigned short); 186 187 // Extra data associated with the underlying resource response. Resource 188 // responses can be copied. If non-null, each copy of a resource response 189 // holds a pointer to the extra data, and the extra data pointer will be 190 // deleted when the last resource response is destroyed. Setting the extra 191 // data pointer will cause the underlying resource response to be 192 // dissociated from any existing non-null extra data pointer. 193 BLINK_PLATFORM_EXPORT ExtraData* extraData() const; 194 BLINK_PLATFORM_EXPORT void setExtraData(ExtraData*); 195 196protected: 197 BLINK_PLATFORM_EXPORT void assign(WebURLResponsePrivate*); 198 199private: 200 WebURLResponsePrivate* m_private; 201}; 202 203} // namespace blink 204 205#endif 206