2 * Copyright (C) 2009 Google Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
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
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.
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.
31 #ifndef WebURLResponse_h
32 #define WebURLResponse_h
34 #include "WebCommon.h"
35 #include "WebPrivateOwnPtr.h"
38 namespace WebCore { class ResourceResponse; }
44 class WebHTTPHeaderVisitor;
45 class WebHTTPLoadInfo;
48 class WebURLLoadTiming;
49 class WebURLResponsePrivate;
51 class WebURLResponse {
53 enum HTTPVersion { Unknown, HTTP_0_9, HTTP_1_0, HTTP_1_1 };
57 virtual ~ExtraData() { }
60 ~WebURLResponse() { reset(); }
62 WebURLResponse() : m_private(0) { }
63 WebURLResponse(const WebURLResponse& r) : m_private(0) { assign(r); }
64 WebURLResponse& operator=(const WebURLResponse& r)
70 explicit WebURLResponse(const WebURL& url) : m_private(0)
76 BLINK_PLATFORM_EXPORT void initialize();
77 BLINK_PLATFORM_EXPORT void reset();
78 BLINK_PLATFORM_EXPORT void assign(const WebURLResponse&);
80 BLINK_PLATFORM_EXPORT bool isNull() const;
82 BLINK_PLATFORM_EXPORT WebURL url() const;
83 BLINK_PLATFORM_EXPORT void setURL(const WebURL&);
85 BLINK_PLATFORM_EXPORT unsigned connectionID() const;
86 BLINK_PLATFORM_EXPORT void setConnectionID(unsigned);
88 BLINK_PLATFORM_EXPORT bool connectionReused() const;
89 BLINK_PLATFORM_EXPORT void setConnectionReused(bool);
91 BLINK_PLATFORM_EXPORT WebURLLoadTiming loadTiming();
92 BLINK_PLATFORM_EXPORT void setLoadTiming(const WebURLLoadTiming&);
94 BLINK_PLATFORM_EXPORT WebHTTPLoadInfo httpLoadInfo();
95 BLINK_PLATFORM_EXPORT void setHTTPLoadInfo(const WebHTTPLoadInfo&);
97 BLINK_PLATFORM_EXPORT double responseTime() const;
98 BLINK_PLATFORM_EXPORT void setResponseTime(double);
100 BLINK_PLATFORM_EXPORT WebString mimeType() const;
101 BLINK_PLATFORM_EXPORT void setMIMEType(const WebString&);
103 BLINK_PLATFORM_EXPORT long long expectedContentLength() const;
104 BLINK_PLATFORM_EXPORT void setExpectedContentLength(long long);
106 BLINK_PLATFORM_EXPORT WebString textEncodingName() const;
107 BLINK_PLATFORM_EXPORT void setTextEncodingName(const WebString&);
109 BLINK_PLATFORM_EXPORT WebString suggestedFileName() const;
110 BLINK_PLATFORM_EXPORT void setSuggestedFileName(const WebString&);
112 BLINK_PLATFORM_EXPORT HTTPVersion httpVersion() const;
113 BLINK_PLATFORM_EXPORT void setHTTPVersion(HTTPVersion);
115 BLINK_PLATFORM_EXPORT int httpStatusCode() const;
116 BLINK_PLATFORM_EXPORT void setHTTPStatusCode(int);
118 BLINK_PLATFORM_EXPORT WebString httpStatusText() const;
119 BLINK_PLATFORM_EXPORT void setHTTPStatusText(const WebString&);
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;
127 BLINK_PLATFORM_EXPORT double lastModifiedDate() const;
128 BLINK_PLATFORM_EXPORT void setLastModifiedDate(double);
130 BLINK_PLATFORM_EXPORT long long appCacheID() const;
131 BLINK_PLATFORM_EXPORT void setAppCacheID(long long);
133 BLINK_PLATFORM_EXPORT WebURL appCacheManifestURL() const;
134 BLINK_PLATFORM_EXPORT void setAppCacheManifestURL(const WebURL&);
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&);
142 BLINK_PLATFORM_EXPORT WebCore::ResourceResponse& toMutableResourceResponse();
143 BLINK_PLATFORM_EXPORT const WebCore::ResourceResponse& toResourceResponse() const;
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);
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);
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);
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);
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);
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);
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&);
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&);
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);
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*);
197 BLINK_PLATFORM_EXPORT void assign(WebURLResponsePrivate*);
200 WebURLResponsePrivate* m_private;
203 } // namespace WebKit