summaryrefslogtreecommitdiffstats
path: root/WebCore/platform/network/curl/ResourceHandleManager.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore/platform/network/curl/ResourceHandleManager.cpp')
-rw-r--r--WebCore/platform/network/curl/ResourceHandleManager.cpp75
1 files changed, 10 insertions, 65 deletions
diff --git a/WebCore/platform/network/curl/ResourceHandleManager.cpp b/WebCore/platform/network/curl/ResourceHandleManager.cpp
index a4d71e0..2e4259c 100644
--- a/WebCore/platform/network/curl/ResourceHandleManager.cpp
+++ b/WebCore/platform/network/curl/ResourceHandleManager.cpp
@@ -34,14 +34,13 @@
#include "config.h"
#include "ResourceHandleManager.h"
-#include "Base64.h"
+#include "DataURL.h"
#include "HTTPParsers.h"
#include "MIMETypeRegistry.h"
#include "NotImplemented.h"
#include "ResourceError.h"
#include "ResourceHandle.h"
#include "ResourceHandleInternal.h"
-#include "TextEncoding.h"
#include <errno.h>
#include <stdio.h>
@@ -121,8 +120,9 @@ static void curl_unlock_callback(CURL* handle, curl_lock_data data, void* userPt
ResourceHandleManager::ResourceHandleManager()
: m_downloadTimer(this, &ResourceHandleManager::downloadTimerCallback)
, m_cookieJarFileName(0)
- , m_runningJobs(0)
, m_certificatePath (certificatePath())
+ , m_runningJobs(0)
+
{
curl_global_init(CURL_GLOBAL_ALL);
m_curlMultiHandle = curl_multi_init();
@@ -164,7 +164,7 @@ static void handleLocalReceiveResponse (CURL* handle, ResourceHandle* job, Resou
// TODO: See if there is a better approach for handling this.
const char* hdr;
CURLcode err = curl_easy_getinfo(handle, CURLINFO_EFFECTIVE_URL, &hdr);
- ASSERT(CURLE_OK == err);
+ ASSERT_UNUSED(err, CURLE_OK == err);
d->m_response.setURL(KURL(ParsedURLString, hdr));
if (d->client())
d->client()->didReceiveResponse(job, d->m_response);
@@ -372,7 +372,7 @@ void ResourceHandleManager::downloadTimerCallback(Timer<ResourceHandleManager>*
ASSERT(handle);
ResourceHandle* job = 0;
CURLcode err = curl_easy_getinfo(handle, CURLINFO_PRIVATE, &job);
- ASSERT(CURLE_OK == err);
+ ASSERT_UNUSED(err, CURLE_OK == err);
ASSERT(job);
if (!job)
continue;
@@ -572,67 +572,12 @@ bool ResourceHandleManager::startScheduledJobs()
return started;
}
-static void parseDataUrl(ResourceHandle* handle)
-{
- ResourceHandleClient* client = handle->client();
-
- ASSERT(client);
- if (!client)
- return;
-
- String url = handle->firstRequest().url().string();
- ASSERT(url.startsWith("data:", false));
-
- int index = url.find(',');
- if (index == -1) {
- client->cannotShowURL(handle);
- return;
- }
-
- String mediaType = url.substring(5, index - 5);
- String data = url.substring(index + 1);
-
- bool base64 = mediaType.endsWith(";base64", false);
- if (base64)
- mediaType = mediaType.left(mediaType.length() - 7);
-
- if (mediaType.isEmpty())
- mediaType = "text/plain;charset=US-ASCII";
-
- String mimeType = extractMIMETypeFromMediaType(mediaType);
- String charset = extractCharsetFromMediaType(mediaType);
-
- ResourceResponse response;
- response.setMimeType(mimeType);
-
- if (base64) {
- data = decodeURLEscapeSequences(data);
- response.setTextEncodingName(charset);
- client->didReceiveResponse(handle, response);
-
- // WebCore's decoder fails on Acid3 test 97 (whitespace).
- Vector<char> out;
- CString latin1 = data.latin1();
- if (base64Decode(latin1.data(), latin1.length(), out) && out.size() > 0)
- client->didReceiveData(handle, out.data(), out.size(), 0);
- } else {
- // We have to convert to UTF-16 early due to limitations in KURL
- data = decodeURLEscapeSequences(data, TextEncoding(charset));
- response.setTextEncodingName("UTF-16");
- client->didReceiveResponse(handle, response);
- if (data.length() > 0)
- client->didReceiveData(handle, reinterpret_cast<const char*>(data.characters()), data.length() * sizeof(UChar), 0);
- }
-
- client->didFinishLoading(handle, 0);
-}
-
void ResourceHandleManager::dispatchSynchronousJob(ResourceHandle* job)
{
KURL kurl = job->firstRequest().url();
- if (kurl.protocolIs("data")) {
- parseDataUrl(job);
+ if (kurl.protocolIsData()) {
+ handleDataURL(job);
return;
}
@@ -662,8 +607,8 @@ void ResourceHandleManager::startJob(ResourceHandle* job)
{
KURL kurl = job->firstRequest().url();
- if (kurl.protocolIs("data")) {
- parseDataUrl(job);
+ if (kurl.protocolIsData()) {
+ handleDataURL(job);
return;
}
@@ -711,7 +656,7 @@ void ResourceHandleManager::initializeHandle(ResourceHandle* job)
CURLcode error = curl_easy_pause(d->m_handle, CURLPAUSE_ALL);
// If we did not pause the handle, we would ASSERT in the
// header callback. So just assert here.
- ASSERT(error == CURLE_OK);
+ ASSERT_UNUSED(error, error == CURLE_OK);
}
#endif
#ifndef NDEBUG