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