|
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 WebURLLoadTiming; |
|
47 class WebURLResponsePrivate; |
|
48 |
|
49 class WebURLResponse { |
|
50 public: |
|
51 ~WebURLResponse() { reset(); } |
|
52 |
|
53 WebURLResponse() : m_private(0) { } |
|
54 WebURLResponse(const WebURLResponse& r) : m_private(0) { assign(r); } |
|
55 WebURLResponse& operator=(const WebURLResponse& r) |
|
56 { |
|
57 assign(r); |
|
58 return *this; |
|
59 } |
|
60 |
|
61 explicit WebURLResponse(const WebURL& url) : m_private(0) |
|
62 { |
|
63 initialize(); |
|
64 setURL(url); |
|
65 } |
|
66 |
|
67 WEBKIT_API void initialize(); |
|
68 WEBKIT_API void reset(); |
|
69 WEBKIT_API void assign(const WebURLResponse&); |
|
70 |
|
71 WEBKIT_API bool isNull() const; |
|
72 |
|
73 WEBKIT_API WebURL url() const; |
|
74 WEBKIT_API void setURL(const WebURL&); |
|
75 |
|
76 WEBKIT_API unsigned connectionID() const; |
|
77 WEBKIT_API void setConnectionID(unsigned); |
|
78 |
|
79 WEBKIT_API bool connectionReused() const; |
|
80 WEBKIT_API void setConnectionReused(bool); |
|
81 |
|
82 WEBKIT_API WebURLLoadTiming loadTiming(); |
|
83 WEBKIT_API void setLoadTiming(const WebURLLoadTiming&); |
|
84 |
|
85 WEBKIT_API double responseTime() const; |
|
86 WEBKIT_API void setResponseTime(double); |
|
87 |
|
88 WEBKIT_API WebString mimeType() const; |
|
89 WEBKIT_API void setMIMEType(const WebString&); |
|
90 |
|
91 WEBKIT_API long long expectedContentLength() const; |
|
92 WEBKIT_API void setExpectedContentLength(long long); |
|
93 |
|
94 WEBKIT_API WebString textEncodingName() const; |
|
95 WEBKIT_API void setTextEncodingName(const WebString&); |
|
96 |
|
97 WEBKIT_API WebString suggestedFileName() const; |
|
98 WEBKIT_API void setSuggestedFileName(const WebString&); |
|
99 |
|
100 WEBKIT_API int httpStatusCode() const; |
|
101 WEBKIT_API void setHTTPStatusCode(int); |
|
102 |
|
103 WEBKIT_API WebString httpStatusText() const; |
|
104 WEBKIT_API void setHTTPStatusText(const WebString&); |
|
105 |
|
106 WEBKIT_API WebString httpHeaderField(const WebString& name) const; |
|
107 WEBKIT_API void setHTTPHeaderField(const WebString& name, const WebString& value); |
|
108 WEBKIT_API void addHTTPHeaderField(const WebString& name, const WebString& value); |
|
109 WEBKIT_API void clearHTTPHeaderField(const WebString& name); |
|
110 WEBKIT_API void visitHTTPHeaderFields(WebHTTPHeaderVisitor*) const; |
|
111 |
|
112 WEBKIT_API double lastModifiedDate() const; |
|
113 WEBKIT_API void setLastModifiedDate(double); |
|
114 |
|
115 WEBKIT_API bool isContentFiltered() const; |
|
116 WEBKIT_API void setIsContentFiltered(bool); |
|
117 |
|
118 WEBKIT_API long long appCacheID() const; |
|
119 WEBKIT_API void setAppCacheID(long long); |
|
120 |
|
121 WEBKIT_API WebURL appCacheManifestURL() const; |
|
122 WEBKIT_API void setAppCacheManifestURL(const WebURL&); |
|
123 |
|
124 // A consumer controlled value intended to be used to record opaque |
|
125 // security info related to this request. |
|
126 WEBKIT_API WebCString securityInfo() const; |
|
127 WEBKIT_API void setSecurityInfo(const WebCString&); |
|
128 |
|
129 #if defined(WEBKIT_IMPLEMENTATION) |
|
130 WebCore::ResourceResponse& toMutableResourceResponse(); |
|
131 const WebCore::ResourceResponse& toResourceResponse() const; |
|
132 #endif |
|
133 |
|
134 // Flag whether this request was served from the disk cache entry. |
|
135 WEBKIT_API bool wasCached() const; |
|
136 WEBKIT_API void setWasCached(bool); |
|
137 |
|
138 // Flag whether this request was loaded via the SPDY protocol or not. |
|
139 // SPDY is an experimental web protocol, see http://dev.chromium.org/spdy |
|
140 WEBKIT_API bool wasFetchedViaSPDY() const; |
|
141 WEBKIT_API void setWasFetchedViaSPDY(bool); |
|
142 |
|
143 // Flag whether this request was loaded after the TLS/Next-Protocol-Negotiation was used. |
|
144 // This is related to SPDY. |
|
145 WEBKIT_API bool wasNpnNegotiated() const; |
|
146 WEBKIT_API void setWasNpnNegotiated(bool); |
|
147 |
|
148 // Flag whether this request was made when "Alternate-Protocol: xxx" |
|
149 // is present in server's response. |
|
150 WEBKIT_API bool wasAlternateProtocolAvailable() const; |
|
151 WEBKIT_API void setWasAlternateProtocolAvailable(bool); |
|
152 |
|
153 // Flag whether this request was loaded via an explicit proxy (HTTP, SOCKS, etc). |
|
154 WEBKIT_API bool wasFetchedViaProxy() const; |
|
155 WEBKIT_API void setWasFetchedViaProxy(bool); |
|
156 |
|
157 // Flag whether this request is part of a multipart response. |
|
158 WEBKIT_API bool isMultipartPayload() const; |
|
159 WEBKIT_API void setIsMultipartPayload(bool); |
|
160 |
|
161 // This indicates the location of a downloaded response if the |
|
162 // WebURLRequest had the downloadToFile flag set to true. This file path |
|
163 // remains valid for the lifetime of the WebURLLoader used to create it. |
|
164 WEBKIT_API WebString downloadFilePath() const; |
|
165 WEBKIT_API void setDownloadFilePath(const WebString&); |
|
166 |
|
167 protected: |
|
168 void assign(WebURLResponsePrivate*); |
|
169 |
|
170 private: |
|
171 WebURLResponsePrivate* m_private; |
|
172 }; |
|
173 |
|
174 } // namespace WebKit |
|
175 |
|
176 #endif |