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"
50 #define LIBSOUP_USE_UNSTABLE_REQUEST_API
51 #include <libsoup/soup-request.h>
52 #include <libsoup/soup.h>
59 class QNetworkReplyHandler;
65 @class NSURLAuthenticationChallenge;
66 @class NSURLConnection;
68 class NSURLAuthenticationChallenge;
69 class NSURLConnection;
73 // The allocations and releases in ResourceHandleInternal are
74 // Cocoa-exception-free (either simple Foundation classes or
75 // WebCoreResourceLoaderImp which avoids doing work in dealloc).
78 class ResourceHandleClient;
80 class ResourceHandleInternal {
81 WTF_MAKE_NONCOPYABLE(ResourceHandleInternal); WTF_MAKE_FAST_ALLOCATED;
83 ResourceHandleInternal(ResourceHandle* loader, const ResourceRequest& request, ResourceHandleClient* c, bool defersLoading, bool shouldContentSniff)
85 , m_firstRequest(request)
86 , m_lastHTTPMethod(request.httpMethod())
88 , m_defersLoading(defersLoading)
89 , m_shouldContentSniff(shouldContentSniff)
94 , m_fileLoadTimer(loader, &ResourceHandle::fileLoadTimer)
98 , m_sentEndRequest(false)
99 , m_bytesRemainingToWrite(0)
100 , m_loadSynchronously(false)
101 , m_hasReceivedResponse(false)
108 , m_formDataStream(loader)
113 , m_finishedHandler(0)
117 , m_gotChunkHandler(0)
123 , m_startWhenScheduled(false)
124 , m_needsSiteSpecificQuirks(false)
125 , m_currentMacChallenge(nil)
127 , m_scheduledFailureType(ResourceHandle::NoFailure)
128 , m_failureTimer(loader, &ResourceHandle::fireFailure)
130 const KURL& url = m_firstRequest.url();
133 m_firstRequest.removeCredentials();
136 ~ResourceHandleInternal();
138 ResourceHandleClient* client() { return m_client; }
139 ResourceHandleClient* m_client;
141 ResourceRequest m_firstRequest;
142 String m_lastHTTPMethod;
144 // Suggested credentials for the current redirection step.
148 Credential m_initialCredential;
152 bool m_defersLoading;
153 bool m_shouldContentSniff;
155 RetainPtr<CFURLConnectionRef> m_connection;
157 #if PLATFORM(MAC) && !USE(CFNETWORK)
158 RetainPtr<NSURLConnection> m_connection;
159 RetainPtr<WebCoreResourceHandleAsDelegate> m_delegate;
160 RetainPtr<id> m_proxy;
163 bool m_startWhenScheduled;
164 bool m_needsSiteSpecificQuirks;
167 Timer<ResourceHandle> m_fileLoadTimer;
168 HINTERNET m_internetHandle;
169 HINTERNET m_connectHandle;
170 HINTERNET m_requestHandle;
171 bool m_sentEndRequest;
172 Vector<char> m_formData;
173 size_t m_bytesRemainingToWrite;
174 bool m_loadSynchronously;
175 bool m_hasReceivedResponse;
176 String m_redirectUrl;
181 struct curl_slist* m_customHeaders;
182 ResourceResponse m_response;
185 FormDataStream m_formDataStream;
186 Vector<char> m_postBytes;
189 GRefPtr<SoupMessage> m_soupMessage;
190 ResourceResponse m_response;
193 gulong m_finishedHandler;
194 GRefPtr<SoupRequest> m_soupRequest;
195 GRefPtr<GInputStream> m_inputStream;
196 GRefPtr<GCancellable> m_cancellable;
198 unsigned long m_bodySize;
199 unsigned long m_bodyDataSent;
200 RefPtr<NetworkingContext> m_context;
201 gulong m_gotChunkHandler;
204 QNetworkReplyHandler* m_job;
205 RefPtr<NetworkingContext> m_context;
209 // We need to keep a reference to the original challenge to be able to cancel it.
210 // It is almost identical to m_currentWebChallenge.nsURLAuthenticationChallenge(), but has a different sender.
211 NSURLAuthenticationChallenge *m_currentMacChallenge;
213 AuthenticationChallenge m_currentWebChallenge;
215 ResourceHandle::FailureType m_scheduledFailureType;
216 Timer<ResourceHandle> m_failureTimer;
219 } // namespace WebCore
221 #endif // ResourceHandleInternal_h