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"
37
#if WEBKIT_IMPLEMENTATION
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
WEBKIT_EXPORT void initialize();
77
WEBKIT_EXPORT void reset();
78
WEBKIT_EXPORT void assign(const WebURLResponse&);
80
WEBKIT_EXPORT bool isNull() const;
82
WEBKIT_EXPORT WebURL url() const;
83
WEBKIT_EXPORT void setURL(const WebURL&);
85
WEBKIT_EXPORT unsigned connectionID() const;
86
WEBKIT_EXPORT void setConnectionID(unsigned);
88
WEBKIT_EXPORT bool connectionReused() const;
89
WEBKIT_EXPORT void setConnectionReused(bool);
91
WEBKIT_EXPORT WebURLLoadTiming loadTiming();
92
WEBKIT_EXPORT void setLoadTiming(const WebURLLoadTiming&);
94
WEBKIT_EXPORT WebHTTPLoadInfo httpLoadInfo();
95
WEBKIT_EXPORT void setHTTPLoadInfo(const WebHTTPLoadInfo&);
97
WEBKIT_EXPORT double responseTime() const;
98
WEBKIT_EXPORT void setResponseTime(double);
100
WEBKIT_EXPORT WebString mimeType() const;
101
WEBKIT_EXPORT void setMIMEType(const WebString&);
103
WEBKIT_EXPORT long long expectedContentLength() const;
104
WEBKIT_EXPORT void setExpectedContentLength(long long);
106
WEBKIT_EXPORT WebString textEncodingName() const;
107
WEBKIT_EXPORT void setTextEncodingName(const WebString&);
109
WEBKIT_EXPORT WebString suggestedFileName() const;
110
WEBKIT_EXPORT void setSuggestedFileName(const WebString&);
112
WEBKIT_EXPORT HTTPVersion httpVersion() const;
113
WEBKIT_EXPORT void setHTTPVersion(HTTPVersion);
115
WEBKIT_EXPORT int httpStatusCode() const;
116
WEBKIT_EXPORT void setHTTPStatusCode(int);
118
WEBKIT_EXPORT WebString httpStatusText() const;
119
WEBKIT_EXPORT void setHTTPStatusText(const WebString&);
121
WEBKIT_EXPORT WebString httpHeaderField(const WebString& name) const;
122
WEBKIT_EXPORT void setHTTPHeaderField(const WebString& name, const WebString& value);
123
WEBKIT_EXPORT void addHTTPHeaderField(const WebString& name, const WebString& value);
124
WEBKIT_EXPORT void clearHTTPHeaderField(const WebString& name);
125
WEBKIT_EXPORT void visitHTTPHeaderFields(WebHTTPHeaderVisitor*) const;
127
WEBKIT_EXPORT double lastModifiedDate() const;
128
WEBKIT_EXPORT void setLastModifiedDate(double);
130
WEBKIT_EXPORT long long appCacheID() const;
131
WEBKIT_EXPORT void setAppCacheID(long long);
133
WEBKIT_EXPORT WebURL appCacheManifestURL() const;
134
WEBKIT_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
WEBKIT_EXPORT WebCString securityInfo() const;
139
WEBKIT_EXPORT void setSecurityInfo(const WebCString&);
141
#if WEBKIT_IMPLEMENTATION
142
WebCore::ResourceResponse& toMutableResourceResponse();
143
const WebCore::ResourceResponse& toResourceResponse() const;
146
// Flag whether this request was served from the disk cache entry.
147
WEBKIT_EXPORT bool wasCached() const;
148
WEBKIT_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
WEBKIT_EXPORT bool wasFetchedViaSPDY() const;
153
WEBKIT_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
WEBKIT_EXPORT bool wasNpnNegotiated() const;
158
WEBKIT_EXPORT void setWasNpnNegotiated(bool);
160
// Flag whether this request was made when "Alternate-Protocol: xxx"
161
// is present in server's response.
162
WEBKIT_EXPORT bool wasAlternateProtocolAvailable() const;
163
WEBKIT_EXPORT void setWasAlternateProtocolAvailable(bool);
165
// Flag whether this request was loaded via an explicit proxy (HTTP, SOCKS, etc).
166
WEBKIT_EXPORT bool wasFetchedViaProxy() const;
167
WEBKIT_EXPORT void setWasFetchedViaProxy(bool);
169
// Flag whether this request is part of a multipart response.
170
WEBKIT_EXPORT bool isMultipartPayload() const;
171
WEBKIT_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
WEBKIT_EXPORT WebString downloadFilePath() const;
177
WEBKIT_EXPORT void setDownloadFilePath(const WebString&);
179
// Remote IP address of the socket which fetched this resource.
180
WEBKIT_EXPORT WebString remoteIPAddress() const;
181
WEBKIT_EXPORT void setRemoteIPAddress(const WebString&);
183
// Remote port number of the socket which fetched this resource.
184
WEBKIT_EXPORT unsigned short remotePort() const;
185
WEBKIT_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
WEBKIT_EXPORT ExtraData* extraData() const;
194
WEBKIT_EXPORT void setExtraData(ExtraData*);
197
void assign(WebURLResponsePrivate*);
200
WebURLResponsePrivate* m_private;
203
} // namespace WebKit