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 WebURLRequest_h
32 #define WebURLRequest_h
34 #include "WebCommon.h"
35 #include "WebHTTPBody.h"
37 #if defined(WEBKIT_IMPLEMENTATION)
38 namespace WebCore { class ResourceRequest; }
45 class WebHTTPHeaderVisitor;
48 class WebURLRequestPrivate;
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
60 TargetIsMainFrame = 0,
62 TargetIsSubresource = 2,
63 TargetIsStyleSheet = 3,
65 TargetIsFontResource = 5,
70 TargetIsSharedWorker = 10,
71 TargetIsPrefetch = 11,
72 TargetIsPrerender = 12,
75 TargetIsTextTrack = 15,
76 TargetIsUnspecified = 16,
81 virtual ~ExtraData() { }
84 ~WebURLRequest() { reset(); }
86 WebURLRequest() : m_private(0) { }
87 WebURLRequest(const WebURLRequest& r) : m_private(0) { assign(r); }
88 WebURLRequest& operator=(const WebURLRequest& r)
94 explicit WebURLRequest(const WebURL& url) : m_private(0)
100 WEBKIT_EXPORT void initialize();
101 WEBKIT_EXPORT void reset();
102 WEBKIT_EXPORT void assign(const WebURLRequest&);
104 WEBKIT_EXPORT bool isNull() const;
106 WEBKIT_EXPORT WebURL url() const;
107 WEBKIT_EXPORT void setURL(const WebURL&);
109 // Used to implement third-party cookie blocking.
110 WEBKIT_EXPORT WebURL firstPartyForCookies() const;
111 WEBKIT_EXPORT void setFirstPartyForCookies(const WebURL&);
113 WEBKIT_EXPORT bool allowCookies() const;
114 WEBKIT_EXPORT void setAllowCookies(bool);
116 // Controls whether user name, password, and cookies may be sent with the
117 // request. (If false, this overrides allowCookies.)
118 WEBKIT_EXPORT bool allowStoredCredentials() const;
119 WEBKIT_EXPORT void setAllowStoredCredentials(bool);
121 WEBKIT_EXPORT CachePolicy cachePolicy() const;
122 WEBKIT_EXPORT void setCachePolicy(CachePolicy);
124 WEBKIT_EXPORT WebString httpMethod() const;
125 WEBKIT_EXPORT void setHTTPMethod(const WebString&);
127 WEBKIT_EXPORT WebString httpHeaderField(const WebString& name) const;
128 WEBKIT_EXPORT void setHTTPHeaderField(const WebString& name, const WebString& value);
129 WEBKIT_EXPORT void addHTTPHeaderField(const WebString& name, const WebString& value);
130 WEBKIT_EXPORT void clearHTTPHeaderField(const WebString& name);
131 WEBKIT_EXPORT void visitHTTPHeaderFields(WebHTTPHeaderVisitor*) const;
133 WEBKIT_EXPORT WebHTTPBody httpBody() const;
134 WEBKIT_EXPORT void setHTTPBody(const WebHTTPBody&);
136 // Controls whether upload progress events are generated when a request
138 WEBKIT_EXPORT bool reportUploadProgress() const;
139 WEBKIT_EXPORT void setReportUploadProgress(bool);
141 // Controls whether load timing info is collected for the request.
142 WEBKIT_EXPORT bool reportLoadTiming() const;
143 WEBKIT_EXPORT void setReportLoadTiming(bool);
145 // Controls whether actual headers sent and received for request are
146 // collected and reported.
147 WEBKIT_EXPORT bool reportRawHeaders() const;
148 WEBKIT_EXPORT void setReportRawHeaders(bool);
150 WEBKIT_EXPORT TargetType targetType() const;
151 WEBKIT_EXPORT void setTargetType(TargetType);
153 // True if the request was user initiated.
154 WEBKIT_EXPORT bool hasUserGesture() const;
155 WEBKIT_EXPORT void setHasUserGesture(bool);
157 // A consumer controlled value intended to be used to identify the
159 WEBKIT_EXPORT int requestorID() const;
160 WEBKIT_EXPORT void setRequestorID(int);
162 // A consumer controlled value intended to be used to identify the
163 // process of the requestor.
164 WEBKIT_EXPORT int requestorProcessID() const;
165 WEBKIT_EXPORT void setRequestorProcessID(int);
167 // Allows the request to be matched up with its app cache host.
168 WEBKIT_EXPORT int appCacheHostID() const;
169 WEBKIT_EXPORT void setAppCacheHostID(int);
171 // If true, the response body will be downloaded to a file managed by the
172 // WebURLLoader. See WebURLResponse::downloadedFilePath.
173 WEBKIT_EXPORT bool downloadToFile() const;
174 WEBKIT_EXPORT void setDownloadToFile(bool);
176 // Extra data associated with the underlying resource request. Resource
177 // requests can be copied. If non-null, each copy of a resource requests
178 // holds a pointer to the extra data, and the extra data pointer will be
179 // deleted when the last resource request is destroyed. Setting the extra
180 // data pointer will cause the underlying resource request to be
181 // dissociated from any existing non-null extra data pointer.
182 WEBKIT_EXPORT ExtraData* extraData() const;
183 WEBKIT_EXPORT void setExtraData(ExtraData*);
185 #if defined(WEBKIT_IMPLEMENTATION)
186 WebCore::ResourceRequest& toMutableResourceRequest();
187 const WebCore::ResourceRequest& toResourceRequest() const;
191 void assign(WebURLRequestPrivate*);
194 WebURLRequestPrivate* m_private;
197 } // namespace WebKit