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"
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 PriorityUnresolved = -1,
69 TargetIsMainFrame = 0,
71 TargetIsSubresource = 2,
72 TargetIsStyleSheet = 3,
74 TargetIsFontResource = 5,
79 TargetIsSharedWorker = 10,
80 TargetIsPrefetch = 11,
83 TargetIsTextTrack = 14,
85 TargetIsServiceWorker = 16,
86 TargetIsUnspecified = 17,
91 virtual ~ExtraData() { }
94 ~WebURLRequest() { reset(); }
96 WebURLRequest() : m_private(0) { }
97 WebURLRequest(const WebURLRequest& r) : m_private(0) { assign(r); }
98 WebURLRequest& operator=(const WebURLRequest& r)
104 explicit WebURLRequest(const WebURL& url) : m_private(0)
110 BLINK_PLATFORM_EXPORT void initialize();
111 BLINK_PLATFORM_EXPORT void reset();
112 BLINK_PLATFORM_EXPORT void assign(const WebURLRequest&);
114 BLINK_PLATFORM_EXPORT bool isNull() const;
116 BLINK_PLATFORM_EXPORT WebURL url() const;
117 BLINK_PLATFORM_EXPORT void setURL(const WebURL&);
119 // Used to implement third-party cookie blocking.
120 BLINK_PLATFORM_EXPORT WebURL firstPartyForCookies() const;
121 BLINK_PLATFORM_EXPORT void setFirstPartyForCookies(const WebURL&);
123 BLINK_PLATFORM_EXPORT bool allowCookies() const;
124 BLINK_PLATFORM_EXPORT void setAllowCookies(bool);
126 // Controls whether user name, password, and cookies may be sent with the
127 // request. (If false, this overrides allowCookies.)
128 BLINK_PLATFORM_EXPORT bool allowStoredCredentials() const;
129 BLINK_PLATFORM_EXPORT void setAllowStoredCredentials(bool);
131 BLINK_PLATFORM_EXPORT CachePolicy cachePolicy() const;
132 BLINK_PLATFORM_EXPORT void setCachePolicy(CachePolicy);
134 BLINK_PLATFORM_EXPORT WebString httpMethod() const;
135 BLINK_PLATFORM_EXPORT void setHTTPMethod(const WebString&);
137 BLINK_PLATFORM_EXPORT WebString httpHeaderField(const WebString& name) const;
138 BLINK_PLATFORM_EXPORT void setHTTPHeaderField(const WebString& name, const WebString& value);
139 BLINK_PLATFORM_EXPORT void addHTTPHeaderField(const WebString& name, const WebString& value);
140 BLINK_PLATFORM_EXPORT void clearHTTPHeaderField(const WebString& name);
141 BLINK_PLATFORM_EXPORT void visitHTTPHeaderFields(WebHTTPHeaderVisitor*) const;
143 BLINK_PLATFORM_EXPORT WebHTTPBody httpBody() const;
144 BLINK_PLATFORM_EXPORT void setHTTPBody(const WebHTTPBody&);
146 // Controls whether upload progress events are generated when a request
148 BLINK_PLATFORM_EXPORT bool reportUploadProgress() const;
149 BLINK_PLATFORM_EXPORT void setReportUploadProgress(bool);
151 // Controls whether load timing info is collected for the request.
152 BLINK_PLATFORM_EXPORT bool reportLoadTiming() const;
153 BLINK_PLATFORM_EXPORT void setReportLoadTiming(bool);
155 // Controls whether actual headers sent and received for request are
156 // collected and reported.
157 BLINK_PLATFORM_EXPORT bool reportRawHeaders() const;
158 BLINK_PLATFORM_EXPORT void setReportRawHeaders(bool);
160 BLINK_PLATFORM_EXPORT TargetType targetType() const;
161 BLINK_PLATFORM_EXPORT void setTargetType(TargetType);
163 // True if the request was user initiated.
164 BLINK_PLATFORM_EXPORT bool hasUserGesture() const;
165 BLINK_PLATFORM_EXPORT void setHasUserGesture(bool);
167 // A consumer controlled value intended to be used to identify the
169 BLINK_PLATFORM_EXPORT int requestorID() const;
170 BLINK_PLATFORM_EXPORT void setRequestorID(int);
172 // A consumer controlled value intended to be used to identify the
173 // process of the requestor.
174 BLINK_PLATFORM_EXPORT int requestorProcessID() const;
175 BLINK_PLATFORM_EXPORT void setRequestorProcessID(int);
177 // Allows the request to be matched up with its app cache host.
178 BLINK_PLATFORM_EXPORT int appCacheHostID() const;
179 BLINK_PLATFORM_EXPORT void setAppCacheHostID(int);
181 // If true, the response body will be downloaded to a file managed by the
182 // WebURLLoader. See WebURLResponse::downloadedFilePath.
183 BLINK_PLATFORM_EXPORT bool downloadToFile() const;
184 BLINK_PLATFORM_EXPORT void setDownloadToFile(bool);
186 // Extra data associated with the underlying resource request. Resource
187 // requests can be copied. If non-null, each copy of a resource requests
188 // holds a pointer to the extra data, and the extra data pointer will be
189 // deleted when the last resource request is destroyed. Setting the extra
190 // data pointer will cause the underlying resource request to be
191 // dissociated from any existing non-null extra data pointer.
192 BLINK_PLATFORM_EXPORT ExtraData* extraData() const;
193 BLINK_PLATFORM_EXPORT void setExtraData(ExtraData*);
195 BLINK_PLATFORM_EXPORT Priority priority() const;
198 BLINK_PLATFORM_EXPORT WebCore::ResourceRequest& toMutableResourceRequest();
199 BLINK_PLATFORM_EXPORT const WebCore::ResourceRequest& toResourceRequest() const;
203 BLINK_PLATFORM_EXPORT void assign(WebURLRequestPrivate*);
206 WebURLRequestPrivate* m_private;