2
* Copyright (C) 2004, 2006 Apple Computer, 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
7
* 1. Redistributions of source code must retain the above copyright
8
* notice, this list of conditions and the following disclaimer.
9
* 2. Redistributions in binary form must reproduce the above copyright
10
* notice, this list of conditions and the following disclaimer in the
11
* documentation and/or other materials provided with the distribution.
13
* THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
14
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
17
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
#ifndef ResourceHandleInternal_h
27
#define ResourceHandleInternal_h
29
#include "ResourceHandle.h"
30
#include "ResourceRequest.h"
31
#include "AuthenticationChallenge.h"
35
#include <CFNetwork/CFURLConnectionPriv.h>
38
#if USE(WININET) || (USE(CURL) && PLATFORM(WIN))
44
#include <curl/curl.h>
45
#include "FormDataStreamCurl.h"
49
#include <wtf/gobject/GRefPtr.h>
50
#define LIBSOUP_USE_UNSTABLE_REQUEST_API
51
#include <libsoup/soup-request.h>
52
#include <libsoup/soup.h>
61
class QNetworkReplyHandler;
66
OBJC_CLASS NSURLAuthenticationChallenge;
67
OBJC_CLASS NSURLConnection;
70
#if PLATFORM(MAC) || USE(CFNETWORK)
71
typedef const struct __CFURLStorageSession* CFURLStorageSessionRef;
74
// The allocations and releases in ResourceHandleInternal are
75
// Cocoa-exception-free (either simple Foundation classes or
76
// WebCoreResourceLoaderImp which avoids doing work in dealloc).
79
class ResourceHandleClient;
81
class ResourceHandleInternal {
82
WTF_MAKE_NONCOPYABLE(ResourceHandleInternal); WTF_MAKE_FAST_ALLOCATED;
84
ResourceHandleInternal(ResourceHandle* loader, const ResourceRequest& request, ResourceHandleClient* c, bool defersLoading, bool shouldContentSniff)
86
, m_firstRequest(request)
87
, m_lastHTTPMethod(request.httpMethod())
89
, m_defersLoading(defersLoading)
90
, m_shouldContentSniff(shouldContentSniff)
95
, m_fileLoadTimer(loader, &ResourceHandle::fileLoadTimer)
99
, m_sentEndRequest(false)
100
, m_bytesRemainingToWrite(0)
101
, m_loadSynchronously(false)
102
, m_hasReceivedResponse(false)
109
, m_formDataStream(loader)
121
, m_startWhenScheduled(false)
122
, m_needsSiteSpecificQuirks(false)
123
, m_currentMacChallenge(nil)
125
, m_scheduledFailureType(ResourceHandle::NoFailure)
126
, m_failureTimer(loader, &ResourceHandle::fireFailure)
128
const KURL& url = m_firstRequest.url();
131
m_firstRequest.removeCredentials();
134
~ResourceHandleInternal();
136
ResourceHandleClient* client() { return m_client; }
137
ResourceHandleClient* m_client;
139
ResourceRequest m_firstRequest;
140
String m_lastHTTPMethod;
142
// Suggested credentials for the current redirection step.
146
Credential m_initialCredential;
150
bool m_defersLoading;
151
bool m_shouldContentSniff;
153
RetainPtr<CFURLConnectionRef> m_connection;
155
#if PLATFORM(MAC) && !USE(CFNETWORK)
156
RetainPtr<NSURLConnection> m_connection;
157
RetainPtr<WebCoreResourceHandleAsDelegate> m_delegate;
158
RetainPtr<id> m_proxy;
161
bool m_startWhenScheduled;
162
bool m_needsSiteSpecificQuirks;
164
#if PLATFORM(MAC) || USE(CFNETWORK)
165
RetainPtr<CFURLStorageSessionRef> m_storageSession;
168
Timer<ResourceHandle> m_fileLoadTimer;
169
HINTERNET m_internetHandle;
170
HINTERNET m_connectHandle;
171
HINTERNET m_requestHandle;
172
bool m_sentEndRequest;
173
Vector<char> m_formData;
174
size_t m_bytesRemainingToWrite;
175
bool m_loadSynchronously;
176
bool m_hasReceivedResponse;
177
String m_redirectUrl;
182
struct curl_slist* m_customHeaders;
183
ResourceResponse m_response;
186
FormDataStream m_formDataStream;
187
Vector<char> m_postBytes;
190
GRefPtr<SoupMessage> m_soupMessage;
191
ResourceResponse m_response;
193
GRefPtr<SoupRequest> m_soupRequest;
194
GRefPtr<GInputStream> m_inputStream;
195
GRefPtr<GCancellable> m_cancellable;
196
GRefPtr<GAsyncResult> m_deferredResult;
197
GRefPtr<GSource> m_timeoutSource;
199
unsigned long m_bodySize;
200
unsigned long m_bodyDataSent;
201
RefPtr<NetworkingContext> m_context;
202
SoupSession* soupSession();
206
Credential credential;
207
AuthenticationChallenge challenge;
208
} m_credentialDataToSaveInPersistentStore;
211
QNetworkReplyHandler* m_job;
212
RefPtr<NetworkingContext> m_context;
216
// We need to keep a reference to the original challenge to be able to cancel it.
217
// It is almost identical to m_currentWebChallenge.nsURLAuthenticationChallenge(), but has a different sender.
218
NSURLAuthenticationChallenge *m_currentMacChallenge;
220
AuthenticationChallenge m_currentWebChallenge;
222
ResourceHandle::FailureType m_scheduledFailureType;
223
Timer<ResourceHandle> m_failureTimer;
226
} // namespace WebCore
228
#endif // ResourceHandleInternal_h