Commit 4c7c632c authored by ggaren's avatar ggaren

Reviewed by Maciej.

        
        Added support for experimental CFNetwork-based loader (not turned on yet).
        
        While I was there, I did the following platform cleanup:
        - Windows now uses USE(WININET) instead of PLATFORM(WIN_OS), to match the
          USE(CFNETWORK) idiom.
        - Removed some #includes of windows.h in platform-independent headers.
        - Changed #ifdef __APPLE__ to PLATFORM(MAC)
        - Fixed some build bustage, including case-sensitive filesystem bustage.

        * loader/loader.cpp:
        (WebCore::Loader::receivedAllData):
        * platform/Cursor.h:
        * platform/KURL.h:
        * platform/ResourceLoader.h:
        * platform/ResourceLoaderClient.h:
        * platform/ResourceLoaderInternal.h:
        (WebCore::ResourceLoaderInternal::ResourceLoaderInternal):
        * platform/cfnet/KURLCFNet.cpp: Added.
        (WebCore::KURL::createCFURL):
        * platform/cfnet/ResourceLoaderCFNet.cpp: Added.
        (WebCore::willSendRequest):
        (WebCore::didReceiveChallenge):
        (WebCore::didCancelChallenge):
        (WebCore::didReceiveResponse):
        (WebCore::didReceiveData):
        (WebCore::didFinishLoading):
        (WebCore::didFail):
        (WebCore::willCacheResponse):
        (WebCore::addHeadersFromString):
        (WebCore::ResourceLoaderInternal::~ResourceLoaderInternal):
        (WebCore::ResourceLoader::~ResourceLoader):
        (WebCore::arrayFromFormData):
        (WebCore::emptyPerform):
        (WebCore::runLoaderThread):
        (WebCore::ResourceLoader::start):
        (WebCore::ResourceLoader::cancel):
        * platform/win/CursorWin.cpp:



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@16089 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent b5506610
......@@ -1222,13 +1222,11 @@
0867D690FE84028FC02AAC07 /* Project object */ = {
isa = PBXProject;
buildConfigurationList = 149C277108902AFE008A9EFC /* Build configuration list for PBXProject "JavaScriptCore" */;
compatibilityVersion = "Xcode 2.4";
hasScannedForEncodings = 1;
mainGroup = 0867D691FE84028FC02AAC07 /* JavaScriptCore */;
productRefGroup = 034768DFFF38A50411DB9C8B /* Products */;
projectDirPath = "";
projectRoot = "";
shouldCheckCompatibility = 1;
targets = (
932F5B3E0822A1C700736975 /* JavaScriptCore */,
935F69F508244FEA003D1A45 /* dftables */,
......
......@@ -165,4 +165,12 @@
#define KXMLCORE_USE_ICU_UNICODE 1
#endif
#if PLATFORM(MAC)
#define KXMLCORE_PLATFORM_CF 1
#endif
#if PLATFORM(WIN)
#define KXMLCORE_USE_WININET 1
#endif
#endif /* KXMLCORE_PLATFORM_H */
2006-08-28 Geoffrey Garen <ggaren@apple.com>
Reviewed by Maciej.
Added support for experimental CFNetwork-based loader (not turned on yet).
While I was there, I did the following platform cleanup:
- Windows now uses USE(WININET) instead of PLATFORM(WIN_OS), to match the
USE(CFNETWORK) idiom.
- Removed some #includes of windows.h in platform-independent headers.
- Changed #ifdef __APPLE__ to PLATFORM(MAC)
- Fixed some build bustage, including case-sensitive filesystem bustage.
* loader/loader.cpp:
(WebCore::Loader::receivedAllData):
* platform/Cursor.h:
* platform/KURL.h:
* platform/ResourceLoader.h:
* platform/ResourceLoaderClient.h:
* platform/ResourceLoaderInternal.h:
(WebCore::ResourceLoaderInternal::ResourceLoaderInternal):
* platform/cfnet/KURLCFNet.cpp: Added.
(WebCore::KURL::createCFURL):
* platform/cfnet/ResourceLoaderCFNet.cpp: Added.
(WebCore::willSendRequest):
(WebCore::didReceiveChallenge):
(WebCore::didCancelChallenge):
(WebCore::didReceiveResponse):
(WebCore::didReceiveData):
(WebCore::didFinishLoading):
(WebCore::didFail):
(WebCore::willCacheResponse):
(WebCore::addHeadersFromString):
(WebCore::ResourceLoaderInternal::~ResourceLoaderInternal):
(WebCore::ResourceLoader::~ResourceLoader):
(WebCore::arrayFromFormData):
(WebCore::emptyPerform):
(WebCore::runLoaderThread):
(WebCore::ResourceLoader::start):
(WebCore::ResourceLoader::cancel):
* platform/win/CursorWin.cpp:
2006-08-28 Justin Garcia <justin.garcia@apple.com>
Reviewed by harrison
......
......@@ -1505,17 +1505,12 @@ bool FrameMac::passMouseDownEventToWidget(Widget* widget)
BOOL wasDeferringLoading = [_bridge defersLoading];
if (!wasDeferringLoading)
[_bridge setDefersLoading:YES];
BOOL wasDeferringTimers = isDeferringTimers();
if (!wasDeferringTimers)
setDeferringTimers(true);
ASSERT(!_sendingEventToSubview);
_sendingEventToSubview = true;
[view mouseDown:_currentEvent];
_sendingEventToSubview = false;
if (!wasDeferringTimers)
setDeferringTimers(false);
if (!wasDeferringLoading)
[_bridge setDefersLoading:NO];
......
......@@ -134,7 +134,7 @@ void Loader::receivedAllData(ResourceLoader* job, PlatformData allData)
} else {
docLoader->setLoadInProgress(true);
object->data(req->buffer(), true);
#ifdef __APPLE__
#if PLATFORM(MAC)
object->setAllData(allData);
#endif
docLoader->setLoadInProgress(false);
......
......@@ -29,7 +29,8 @@
#include <wtf/Platform.h>
#if PLATFORM(WIN)
#include <windows.h>
typedef struct HICON__* HICON;
typedef HICON HCURSOR;
#elif PLATFORM(GDK)
#include <gdk/gdk.h>
#elif PLATFORM(QT)
......
......@@ -23,12 +23,17 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef KURL_H_
#define KURL_H_
#ifndef KURL_h
#define KURL_h
#include <wtf/Platform.h>
#include "TextEncoding.h"
#if __APPLE__
#if USE(CFNETWORK)
#include <CoreFoundation/CFURL.h>
#endif
#if PLATFORM(MAC)
#ifdef __OBJC__
@class NSData;
@class NSURL;
......@@ -52,7 +57,7 @@ public:
KURL(const char*);
KURL(const KURL&, const DeprecatedString&, const TextEncoding& encoding = TextEncoding(UTF8Encoding));
KURL(const DeprecatedString&);
#if __APPLE__
#if PLATFORM(MAC)
KURL(NSURL*);
#endif
......@@ -86,8 +91,10 @@ public:
DeprecatedString prettyURL() const;
#if __APPLE__
#if PLATFORM(CF)
CFURLRef createCFURL() const;
#endif
#if PLATFORM(MAC)
NSURL *getNSURL() const;
#endif
......@@ -119,4 +126,4 @@ private:
}
#endif
#endif // KURL_h
......@@ -23,8 +23,8 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef ResourceLoader_H_
#define ResourceLoader_H_
#ifndef ResourceLoader_h
#define ResourceLoader_h
#include "ResourceLoaderClient.h" // for PlatformResponse
#include "StringHash.h"
......@@ -83,7 +83,8 @@ public:
#if PLATFORM(MAC)
void setLoader(WebCoreResourceLoaderImp*);
#endif
#if PLATFORM(WIN)
#if USE(WININET)
void fileLoadTimer(Timer<ResourceLoader>* timer);
friend void __stdcall transferJobStatusCallback(HINTERNET, DWORD_PTR, DWORD, LPVOID, DWORD);
friend LRESULT __stdcall ResourceLoaderWndProc(HWND, unsigned message, WPARAM, LPARAM);
......@@ -108,4 +109,4 @@ private:
}
#endif // ResourceLoader_H_
#endif // ResourceLoader_h
......@@ -26,6 +26,11 @@
#ifndef ResourceLoaderClient_h
#define ResourceLoaderClient_h
#include <wtf/Platform.h>
#if USE(CFNETWORK)
#include <CFNetwork/CFURLResponsePriv.h>
#endif
#if PLATFORM(MAC)
#ifdef __OBJC__
@class NSData;
......@@ -42,7 +47,10 @@ class NSURLResponse;
namespace WebCore {
#if PLATFORM(MAC)
#if USE(CFNETWORK)
typedef void* PlatformData; // unused for now
typedef CFURLResponseRef PlatformResponse;
#elif PLATFORM(MAC)
typedef NSData* PlatformData;
typedef NSURLResponse* PlatformResponse;
#elif PLATFORM(QT)
......@@ -50,8 +58,8 @@ namespace WebCore {
typedef QString PlatformResponse;
#else
// Not sure what the strategy for this will be on other platforms.
typedef struct PlatformDataStruct *PlatformData;
typedef struct PlatformResponseStruct *PlatformResponse;
typedef struct PlatformDataStruct* PlatformData;
typedef struct PlatformResponseStruct* PlatformResponse;
#endif
class KURL;
......
......@@ -24,15 +24,19 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef ResourceLoaderInternal_H_
#define ResourceLoaderInternal_H_
#ifndef ResourceLoaderInternal_h
#define ResourceLoaderInternal_h
#include "FormData.h"
#include "KURL.h"
#include <wtf/HashMap.h>
#include <wtf/Platform.h>
#if PLATFORM(WIN)
#if USE(CFNETWORK)
#include <CFNetwork/CFURLConnectionPriv.h>
#endif
#if USE(WININET)
typedef void* HANDLE;
#endif
......@@ -61,11 +65,13 @@ namespace WebCore {
, method(method)
, assembledResponseHeaders(true)
, retrievedCharset(true)
#if __APPLE__
#if USE(CFNETWORK)
, m_connection(0)
#elif PLATFORM(MAC)
, loader(nil)
, response(nil)
#endif
#if PLATFORM(WIN)
#if USE(WININET)
, m_fileHandle(0)
, m_fileLoadTimer(job, &ResourceLoader::fileLoadTimer)
, m_resourceHandle(0)
......@@ -91,11 +97,13 @@ namespace WebCore {
, postData(p)
, assembledResponseHeaders(true)
, retrievedCharset(true)
#if __APPLE__
#if USE(CFNETWORK)
, m_connection(0)
#elif PLATFORM(MAC)
, loader(nil)
, response(nil)
#endif
#if PLATFORM(WIN)
#if USE(WININET)
, m_fileHandle(0)
, m_fileLoadTimer(job, &ResourceLoader::fileLoadTimer)
, m_resourceHandle(0)
......@@ -127,11 +135,13 @@ namespace WebCore {
bool retrievedCharset;
DeprecatedString responseHeaders;
#if __APPLE__
#if USE(CFNETWORK)
CFURLConnectionRef m_connection;
#elif PLATFORM(MAC)
WebCoreResourceLoaderImp* loader;
NSURLResponse* response;
#endif
#if PLATFORM(WIN)
#if USE(WININET)
HANDLE m_fileHandle;
Timer<ResourceLoader> m_fileLoadTimer;
HINTERNET m_resourceHandle;
......@@ -151,9 +161,8 @@ namespace WebCore {
CURL *m_handle;
QString response;
#endif
};
} // namespace WebCore
#endif // ResourceLoaderInternal_H_
#endif // ResourceLoaderInternal_h
/*
* Copyright (C) 2004 Apple Computer, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "KURL.h"
using namespace std;
namespace WebCore {
#if PLATFORM(CF)
CFURLRef KURL::createCFURL() const
{
const UInt8 *bytes = (const UInt8 *)urlString.latin1();
// NOTE: We use UTF-8 here since this encoding is used when computing strings when returning URL components
// (e.g calls to NSURL -path). However, this function is not tolerant of illegal UTF-8 sequences, which
// could either be a malformed string or bytes in a different encoding, like Shift-JIS, so we fall back
// onto using ISO Latin-1 in those cases.
CFURLRef result = CFURLCreateAbsoluteURLWithBytes(0, bytes, urlString.length(), kCFStringEncodingUTF8, 0, true);
if (!result)
result = CFURLCreateAbsoluteURLWithBytes(0, bytes, urlString.length(), kCFStringEncodingISOLatin1, 0, true);
return result;
}
#endif
}
/*
* Copyright (C) 2004, 2006 Apple Computer, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <wtf/platform.h>
#if USE(CFNETWORK)
#include "config.h"
#include "ResourceLoader.h"
#include "ResourceLoaderInternal.h"
#include "DocLoader.h"
#include "Frame.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <process.h> // for _beginthread()
#include <CFNetwork/CFNetwork.h>
#include <CFNetwork/CFNetworkPriv.h>
//#define LOG_RESOURCELOADER_EVENTS 1
namespace WebCore {
CFURLRequestRef willSendRequest(CFURLConnectionRef conn, CFURLRequestRef request, CFURLResponseRef redirectionResponse, const void* clientInfo)
{
ResourceLoader* job = (ResourceLoader*)clientInfo;
CFURLRef url = CFURLRequestGetURL(request);
CFStringRef urlString = CFURLGetString(url);
const char *bytes = CFStringGetCStringPtr(urlString, kCFStringEncodingUTF8);
bool freeBytes = false;
#if defined(LOG_RESOURCELOADER_EVENTS)
CFStringRef str = CFStringCreateWithFormat(0, 0, CFSTR("willSendRequest(conn=%p, job = %p)\n"), conn, job);
CFShow(str);
CFRelease(str);
#endif
if (!bytes) {
CFIndex numBytes, urlLength = CFStringGetLength(urlString);
UInt8* newBytes;
CFStringGetBytes(urlString, CFRangeMake(0, urlLength), kCFStringEncodingUTF8, 0, FALSE, 0, 0, &numBytes);
newBytes = (UInt8*)malloc(numBytes + 1);
CFStringGetBytes(urlString, CFRangeMake(0, urlLength), kCFStringEncodingUTF8, 0, FALSE, newBytes, numBytes, &numBytes);
newBytes[numBytes] = 0;
freeBytes = true;
bytes = (char*)newBytes;
}
ASSERT(bytes);
KURL newURL(bytes);
if (!(newURL == job->url()))
job->client()->receivedRedirect(job, newURL);
if (freeBytes)
free((void*)bytes);
return request;
}
void didReceiveChallenge(CFURLConnectionRef conn, CFURLAuthChallengeRef challenge, const void* clientInfo)
{
ResourceLoader* job = (ResourceLoader*)clientInfo;
// Do nothing right now
}
void didCancelChallenge(CFURLConnectionRef conn, CFURLAuthChallengeRef challenge, const void* clientInfo)
{
ResourceLoader* job = (ResourceLoader*)clientInfo;
// Do nothing right now
}
void didReceiveResponse(CFURLConnectionRef conn, CFURLResponseRef response, const void* clientInfo)
{
ResourceLoader* job = (ResourceLoader*)clientInfo;
#if defined(LOG_RESOURCELOADER_EVENTS)
CFStringRef str = CFStringCreateWithFormat(0, 0, CFSTR("didReceiveResponse(conn=%p, job = %p)\n"), conn, job);
CFShow(str);
CFRelease(str);
#endif
job->client()->receivedResponse(job, response);
}
void didReceiveData(CFURLConnectionRef conn, CFDataRef data, CFIndex originalLength, const void* clientInfo)
{
ResourceLoader* job = (ResourceLoader*)clientInfo;
const UInt8* bytes = CFDataGetBytePtr(data);
CFIndex length = CFDataGetLength(data);
#if defined(LOG_RESOURCELOADER_EVENTS)
CFStringRef str = CFStringCreateWithFormat(0, 0, CFSTR("didReceiveData(conn=%p, job = %p, numBytes = %d)\n"), conn, job, length);
CFShow(str);
CFRelease(str);
#endif
job->client()->receivedData(job, (const char*)bytes, length);
}
void didFinishLoading(CFURLConnectionRef conn, const void* clientInfo)
{
ResourceLoader* job = (ResourceLoader*)clientInfo;
#if defined(LOG_RESOURCELOADER_EVENTS)
CFStringRef str = CFStringCreateWithFormat(0, 0, CFSTR("didFinishLoading(conn=%p, job = %p)\n"), conn, job);
CFShow(str);
CFRelease(str);
#endif
job->client()->receivedAllData(job, 0);
job->client()->receivedAllData(job);
}
void didFail(CFURLConnectionRef conn, CFStreamError error, const void* clientInfo)
{
ResourceLoader* job = (ResourceLoader*)clientInfo;
#if defined(LOG_RESOURCELOADER_EVENTS)
CFStringRef str = CFStringCreateWithFormat(0, 0, CFSTR("didFail(conn=%p, job = %p, error = {%d, %d})\n"), conn, job, error.domain, error.error);
CFShow(str);
CFRelease(str);
#endif
job->setError(1);
job->client()->receivedAllData(job, 0);
job->client()->receivedAllData(job);
}
CFURLCachedResponseRef willCacheResponse(CFURLConnectionRef conn, CFURLCachedResponseRef cachedResponse, const void* clientInfo)
{
ResourceLoader* job = (ResourceLoader*)clientInfo;
return cachedResponse;
}
const unsigned BUF_LENGTH = 500;
const char* dummyBytes = "GET / HTTP/1.1\r\n";
void addHeadersFromString(CFHTTPMessageRef request, CFStringRef headerString)
{
CFIndex headerLength = CFStringGetLength(headerString);
if (headerLength == 0)
return;
CFHTTPMessageRef dummy = CFHTTPMessageCreateEmpty(0, TRUE);
CFHTTPMessageAppendBytes(dummy, (const UInt8*)dummyBytes, strlen(dummyBytes));
UInt8 buffer[BUF_LENGTH];
UInt8* bytes = buffer;
CFIndex numBytes;
if (headerLength != CFStringGetBytes(headerString, CFRangeMake(0, headerLength), kCFStringEncodingUTF8, 0, FALSE, bytes, BUF_LENGTH, &numBytes)) {
CFStringGetBytes(headerString, CFRangeMake(0, headerLength), kCFStringEncodingUTF8, 0, FALSE, 0, 0, &numBytes);
bytes = (UInt8 *)malloc(numBytes);
CFStringGetBytes(headerString, CFRangeMake(0, headerLength), kCFStringEncodingUTF8, 0, FALSE, bytes, numBytes, &numBytes);
}
CFHTTPMessageAppendBytes(dummy, bytes, numBytes);
if (bytes != buffer)
free(bytes);
CFDictionaryRef allHeaders = CFHTTPMessageCopyAllHeaderFields(dummy);
CFRelease(dummy);
_CFHTTPMessageSetMultipleHeaderFields(request, allHeaders);
CFRelease(allHeaders);
}
ResourceLoaderInternal::~ResourceLoaderInternal()
{
if (m_connection) {
#if defined(LOG_RESOURCELOADER_EVENTS)
CFStringRef str = CFStringCreateWithFormat(0, 0, CFSTR("Cancelling connection %p\n"), m_connection);
CFShow(str);
CFRelease(str);
#endif
CFURLConnectionCancel(m_connection);
CFRelease(m_connection);
m_connection = 0;
}
}
ResourceLoader::~ResourceLoader()
{
#if defined(LOG_RESOURCELOADER_EVENTS)
CFStringRef str = CFStringCreateWithFormat(0, 0, CFSTR("Destroying job %p\n"), this);
CFShow(str);
CFRelease(str);
#endif
delete d;
}
CFArrayRef arrayFromFormData(const FormData& d)
{
CFMutableArrayRef a = CFArrayCreateMutable(0, d.count(), &kCFTypeArrayCallBacks);
for (DeprecatedValueListConstIterator<FormDataElement> it = d.begin(); it != d.end(); ++it) {
const FormDataElement& e = *it;
if (e.m_type == FormDataElement::data) {
CFDataRef data = CFDataCreate(0, (const UInt8*)e.m_data.data(), e.m_data.size());
CFArrayAppendValue(a, data);
CFRelease(data);
} else {
ASSERT(e.m_type == FormDataElement::encodedFile);
int len;
const char* bytes = e.m_filename.ascii(); // !!! Not a good assumption. We need to yank the DeprecatedString to CFString conversions from the Mac-only code
CFStringRef filename = CFStringCreateWithBytes(0, (const UInt8*)bytes, e.m_filename.length(), kCFStringEncodingUTF8, false);
CFArrayAppendValue(a, filename);
CFRelease(filename);
}
}
return a;
}
void emptyPerform(void* unused)
{
}
#if defined(LOADER_THREAD)
static CFRunLoopRef loaderRL = 0;
void runLoaderThread(void *unused)
{
loaderRL = CFRunLoopGetCurrent();
// Must add a source to the run loop to prevent CFRunLoopRun() from exiting
CFRunLoopSourceContext ctxt = {0, (void *)1 /*must be non-NULL*/, 0, 0, 0, 0, 0, 0, 0, emptyPerform};
CFRunLoopSourceRef bogusSource = CFRunLoopSourceCreate(0, 0, &ctxt);
CFRunLoopAddSource(loaderRL, bogusSource,kCFRunLoopDefaultMode);
CFRunLoopRun();
}
#endif
bool ResourceLoader::start(DocLoader* docLoader)
{
CFURLRef url = d->URL.createCFURL();
String str = d->method;
CFStringRef requestMethod = CFStringCreateWithCharacters(0, (const UniChar *)str.characters(), str.length());
Boolean isPost = CFStringCompare(requestMethod, CFSTR("POST"), kCFCompareCaseInsensitive);
CFHTTPMessageRef httpRequest = CFHTTPMessageCreateRequest(0, requestMethod, url, kCFHTTPVersion1_1);
CFRelease(requestMethod);
str = queryMetaData("customHTTPHeader");
CFStringRef headerString = CFStringCreateWithCharacters(0, (const UniChar *)str.characters(), str.length());
if (headerString) {
addHeadersFromString(httpRequest, headerString);
CFRelease(headerString);
}
DeprecatedString referrer = docLoader->frame()->referrer();
if (!referrer.isEmpty() && referrer.isAllASCII()) {
int len;
const char* bytes = referrer.ascii();
CFStringRef str = CFStringCreateWithBytes(0, (const UInt8*)bytes, referrer.length(), kCFStringEncodingUTF8, false);
CFHTTPMessageSetHeaderFieldValue(httpRequest, CFSTR("Referer"),str);
CFRelease(str);
}
CFReadStreamRef bodyStream = 0;
if (postData().count() > 0) {
CFArrayRef formArray = arrayFromFormData(postData());
bool done = false;
CFIndex count = CFArrayGetCount(formArray);
if (count == 1) {