|
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 WebURLRequest_h |
|
32 #define WebURLRequest_h |
|
33 |
|
34 #include "WebCommon.h" |
|
35 #include "WebHTTPBody.h" |
|
36 |
|
37 #if defined(WEBKIT_IMPLEMENTATION) |
|
38 namespace WebCore { class ResourceRequest; } |
|
39 #endif |
|
40 |
|
41 namespace WebKit { |
|
42 |
|
43 class WebCString; |
|
44 class WebHTTPBody; |
|
45 class WebHTTPHeaderVisitor; |
|
46 class WebString; |
|
47 class WebURL; |
|
48 class WebURLRequestPrivate; |
|
49 |
|
50 class WebURLRequest { |
|
51 public: |
|
52 enum CachePolicy { |
|
53 UseProtocolCachePolicy, // normal load |
|
54 ReloadIgnoringCacheData, // reload |
|
55 ReturnCacheDataElseLoad, // back/forward or encoding change - allow stale data |
|
56 ReturnCacheDataDontLoad, // results of a post - allow stale data and only use cache |
|
57 }; |
|
58 |
|
59 enum TargetType { |
|
60 TargetIsMainFrame = 0, |
|
61 TargetIsSubFrame = 1, // Temporary for backward compatibility. |
|
62 TargetIsSubframe = 1, |
|
63 TargetIsSubResource = 2, // Temporary for backward comptibility. |
|
64 TargetIsSubresource = 2, |
|
65 TargetIsStyleSheet = 3, |
|
66 TargetIsScript = 4, |
|
67 TargetIsFontResource = 5, |
|
68 TargetIsImage = 6, |
|
69 TargetIsObject = 7, |
|
70 TargetIsMedia = 8, |
|
71 TargetIsWorker = 9, |
|
72 TargetIsSharedWorker = 10, |
|
73 TargetIsPrefetch = 11, |
|
74 }; |
|
75 |
|
76 ~WebURLRequest() { reset(); } |
|
77 |
|
78 WebURLRequest() : m_private(0) { } |
|
79 WebURLRequest(const WebURLRequest& r) : m_private(0) { assign(r); } |
|
80 WebURLRequest& operator=(const WebURLRequest& r) |
|
81 { |
|
82 assign(r); |
|
83 return *this; |
|
84 } |
|
85 |
|
86 explicit WebURLRequest(const WebURL& url) : m_private(0) |
|
87 { |
|
88 initialize(); |
|
89 setURL(url); |
|
90 } |
|
91 |
|
92 WEBKIT_API void initialize(); |
|
93 WEBKIT_API void reset(); |
|
94 WEBKIT_API void assign(const WebURLRequest&); |
|
95 |
|
96 WEBKIT_API bool isNull() const; |
|
97 |
|
98 WEBKIT_API WebURL url() const; |
|
99 WEBKIT_API void setURL(const WebURL&); |
|
100 |
|
101 // Used to implement third-party cookie blocking. |
|
102 WEBKIT_API WebURL firstPartyForCookies() const; |
|
103 WEBKIT_API void setFirstPartyForCookies(const WebURL&); |
|
104 |
|
105 WEBKIT_API bool allowCookies() const; |
|
106 WEBKIT_API void setAllowCookies(bool allowCookies); |
|
107 |
|
108 // Controls whether user name, password, and cookies may be sent with the |
|
109 // request. (If false, this overrides allowCookies.) |
|
110 WEBKIT_API bool allowStoredCredentials() const; |
|
111 WEBKIT_API void setAllowStoredCredentials(bool allowStoredCredentials); |
|
112 |
|
113 WEBKIT_API CachePolicy cachePolicy() const; |
|
114 WEBKIT_API void setCachePolicy(CachePolicy); |
|
115 |
|
116 WEBKIT_API WebString httpMethod() const; |
|
117 WEBKIT_API void setHTTPMethod(const WebString&); |
|
118 |
|
119 WEBKIT_API WebString httpHeaderField(const WebString& name) const; |
|
120 WEBKIT_API void setHTTPHeaderField(const WebString& name, const WebString& value); |
|
121 WEBKIT_API void addHTTPHeaderField(const WebString& name, const WebString& value); |
|
122 WEBKIT_API void clearHTTPHeaderField(const WebString& name); |
|
123 WEBKIT_API void visitHTTPHeaderFields(WebHTTPHeaderVisitor*) const; |
|
124 |
|
125 WEBKIT_API WebHTTPBody httpBody() const; |
|
126 WEBKIT_API void setHTTPBody(const WebHTTPBody&); |
|
127 |
|
128 // Controls whether upload progress events are generated when a request |
|
129 // has a body. |
|
130 WEBKIT_API bool reportUploadProgress() const; |
|
131 WEBKIT_API void setReportUploadProgress(bool); |
|
132 |
|
133 // Controls whether load timing info is collected for the request. |
|
134 WEBKIT_API bool reportLoadTiming() const; |
|
135 WEBKIT_API void setReportLoadTiming(bool); |
|
136 |
|
137 WEBKIT_API TargetType targetType() const; |
|
138 WEBKIT_API void setTargetType(TargetType); |
|
139 |
|
140 // A consumer controlled value intended to be used to identify the |
|
141 // requestor. |
|
142 WEBKIT_API int requestorID() const; |
|
143 WEBKIT_API void setRequestorID(int); |
|
144 |
|
145 // A consumer controlled value intended to be used to identify the |
|
146 // process of the requestor. |
|
147 WEBKIT_API int requestorProcessID() const; |
|
148 WEBKIT_API void setRequestorProcessID(int); |
|
149 |
|
150 // Allows the request to be matched up with its app cache host. |
|
151 WEBKIT_API int appCacheHostID() const; |
|
152 WEBKIT_API void setAppCacheHostID(int id); |
|
153 |
|
154 // If true, the response body will be downloaded to a file managed by the |
|
155 // WebURLLoader. See WebURLResponse::downloadedFilePath. |
|
156 WEBKIT_API bool downloadToFile() const; |
|
157 WEBKIT_API void setDownloadToFile(bool); |
|
158 |
|
159 #if defined(WEBKIT_IMPLEMENTATION) |
|
160 WebCore::ResourceRequest& toMutableResourceRequest(); |
|
161 const WebCore::ResourceRequest& toResourceRequest() const; |
|
162 #endif |
|
163 |
|
164 protected: |
|
165 void assign(WebURLRequestPrivate*); |
|
166 |
|
167 private: |
|
168 WebURLRequestPrivate* m_private; |
|
169 }; |
|
170 |
|
171 } // namespace WebKit |
|
172 |
|
173 #endif |