[curl] Set the http response status text
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 18 Jun 2013 06:09:40 +0000 (06:09 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 18 Jun 2013 06:09:40 +0000 (06:09 +0000)
https://bugs.webkit.org/show_bug.cgi?id=117307

Patch by Peter Gal <galpeter@inf.u-szeged.hu> on 2013-06-17
Reviewed by Brent Fulgham.

No new tests, covered by existing ones.

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

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

Source/WebCore/ChangeLog
Source/WebCore/platform/network/curl/ResourceHandleManager.cpp

index dff93ce..cab412c 100644 (file)
@@ -1,3 +1,15 @@
+2013-06-17  Peter Gal  <galpeter@inf.u-szeged.hu>
+
+        [curl] Set the http response status text
+        https://bugs.webkit.org/show_bug.cgi?id=117307
+
+        Reviewed by Brent Fulgham.
+
+        No new tests, covered by existing ones.
+
+        * platform/network/curl/ResourceHandleManager.cpp:
+        (WebCore::headerCallback):
+
 2013-06-14  Brent Fulgham  <bfulgham@apple.com>
 
         AX: Correct accessibility role when -webkit-box:display is used.
index 60d2f22..ea300cb 100644 (file)
@@ -366,6 +366,25 @@ static size_t headerCallback(char* ptr, size_t size, size_t nmemb, void* data)
                 d->m_response.addHTTPHeaderField(key, value);
             else
                 d->m_response.setHTTPHeaderField(key, value);
+        } else if (header.startsWith("HTTP", false)) {
+            // This is the first line of the response.
+            // Extract the http status text from this.
+            //
+            // If the FOLLOWLOCATION option is enabled for the curl handle then
+            // curl will follow the redirections internally. Thus this header callback
+            // will be called more than one time with the line starting "HTTP" for one job.
+            long httpCode = 0;
+            curl_easy_getinfo(d->m_handle, CURLINFO_RESPONSE_CODE, &httpCode);
+
+            String httpCodeString = String::number(httpCode);
+            int statusCodePos = header.find(httpCodeString);
+
+            if (statusCodePos != -1) {
+                // The status text is after the status code.
+                String status = header.substring(statusCodePos + httpCodeString.length());
+                d->m_response.setHTTPStatusText(status.stripWhiteSpace());
+            }
+
         }
     }