2007-12-08 Kevin Ollivier <kevino@theolliviers.com>
authoralp@webkit.org <alp@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 9 Dec 2007 00:32:55 +0000 (00:32 +0000)
committeralp@webkit.org <alp@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 9 Dec 2007 00:32:55 +0000 (00:32 +0000)
        Reviewed by Alp Toker.

        http://bugs.webkit.org/show_bug.cgi?id=14651
        [CURL] didReceiveResponse() only called for HTTP loads

        http://bugs.webkit.org/show_bug.cgi?id=14583
        [GDK] file:// relative CSS include URLs handled incorrectly

        Make sure CURL sets the ResourceResponse URL and calls
        didReceiveResponse for local files too.

        * platform/network/curl/ResourceHandleManager.cpp:
        (WebCore::writeCallback):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@28569 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebCore/ChangeLog
WebCore/platform/network/curl/ResourceHandleManager.cpp
WebCore/platform/network/curl/ResourceResponse.h

index bba58a8df3de492a0c719f494c80ee1562c1ca09..967e3caac279a73be2281e0b9b1f45c3d23ce464 100644 (file)
@@ -1,3 +1,19 @@
+2007-12-08  Kevin Ollivier  <kevino@theolliviers.com>
+
+        Reviewed by Alp Toker.
+
+        http://bugs.webkit.org/show_bug.cgi?id=14651
+        [CURL] didReceiveResponse() only called for HTTP loads
+
+        http://bugs.webkit.org/show_bug.cgi?id=14583
+        [GDK] file:// relative CSS include URLs handled incorrectly
+
+        Make sure CURL sets the ResourceResponse URL and calls
+        didReceiveResponse for local files too. 
+
+        * platform/network/curl/ResourceHandleManager.cpp:
+        (WebCore::writeCallback):
+
 2007-12-08  Oliver Hunt  <oliver@apple.com>
 
         Reviewed by Sam W.
index e3dbe5da48001ff8c81c8ef503f48d9a03591c64..8f7d243f4b489fd2e2112a8316d7ce9ae0b9c600 100644 (file)
@@ -94,6 +94,20 @@ static size_t writeCallback(void* ptr, size_t size, size_t nmemb, void* data)
     if (CURLE_OK == err && httpCode >= 300 && httpCode < 400)
         return totalSize;
 
+    // since the code in headerCallback will not have run for local files
+    // the code to set the URL and fire didReceiveResponse is never run,
+    // which means the ResourceLoader's response does not contain the URL.
+    // Run the code here for local files to resolve the issue.
+    // TODO: See if there is a better approach for handling this.
+    if (!d->m_response.responseFired()) {
+        const char* hdr;
+        err = curl_easy_getinfo(h, CURLINFO_EFFECTIVE_URL, &hdr);
+        d->m_response.setUrl(KURL(hdr));
+        if (d->client())
+            d->client()->didReceiveResponse(job, d->m_response);
+        d->m_response.setResponseFired(true);
+    }
+
     if (d->client())
         d->client()->didReceiveData(job, static_cast<char*>(ptr), totalSize, 0);
     return totalSize;
@@ -161,6 +175,8 @@ static size_t headerCallback(char* ptr, size_t size, size_t nmemb, void* data)
 
         if (client)
             client->didReceiveResponse(job, d->m_response);
+        d->m_response.setResponseFired(true);
+
     } else {
         int splitPos = header.find(":");
         if (splitPos != -1)
index 3bb8a734d4c24b61ad1840756ec84fbe7cfddd85..00f154ebb1a235d7304081598794b556ff3fad68 100644 (file)
@@ -34,14 +34,19 @@ namespace WebCore {
 class ResourceResponse : public ResourceResponseBase {
 public:
     ResourceResponse()
-        : ResourceResponseBase(false)
+        : ResourceResponseBase(false),
+          m_responseFired(false)
     {
     }
 
     ResourceResponse(const KURL& url, const String& mimeType, long long expectedLength, const String& textEncodingName, const String& filename)
-        : ResourceResponseBase(url, mimeType, expectedLength, textEncodingName, filename)
+        : ResourceResponseBase(url, mimeType, expectedLength, textEncodingName, filename),
+          m_responseFired(false)
     {
     }
+    
+    void setResponseFired(bool fired) { m_responseFired = fired; }
+    bool responseFired() { return m_responseFired; }
 
 private:
     friend class ResourceResponseBase;
@@ -49,6 +54,8 @@ private:
     void doUpdateResourceResponse()
     {
     }
+    
+    bool m_responseFired;
 
 };