gnash-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnash-commit] /srv/bzr/gnash/trunk r10411: Instruct libcurl NOT to send


From: Sandro Santilli
Subject: [Gnash-commit] /srv/bzr/gnash/trunk r10411: Instruct libcurl NOT to send an Expect: header, as some older http servers choke on it.
Date: Sat, 13 Dec 2008 00:29:08 +0100
User-agent: Bazaar (1.5)

------------------------------------------------------------
revno: 10411
committer: Sandro Santilli <address@hidden>
branch nick: trunk
timestamp: Sat 2008-12-13 00:29:08 +0100
message:
  Instruct libcurl NOT to send an Expect: header, as some older http servers 
choke on it.
  In particular, the lighthttp version used by openstreetmap.org had the 
problem, and this patch fixes potlatch for me.
modified:
  libbase/curl_adapter.cpp
=== modified file 'libbase/curl_adapter.cpp'
--- a/libbase/curl_adapter.cpp  2008-11-14 00:46:35 +0000
+++ b/libbase/curl_adapter.cpp  2008-12-12 23:29:08 +0000
@@ -484,7 +484,8 @@
        static size_t recv(void *buf, size_t  size,
                size_t  nmemb, void *userp);
 
-
+    // List of custom headers for this stream.
+    struct curl_slist *_customHeaders;
 };
 
 
@@ -745,6 +746,8 @@
 void
 CurlStreamFile::init(const std::string& url)
 {
+    _customHeaders = 0;
+
        _url = url;
        _running = 1;
        _error = 0;
@@ -902,6 +905,23 @@
                throw gnash::GnashException(curl_easy_strerror(ccode));
        }
 
+    // Disable sending an Expect: header, as some older HTTP/1.1
+    // don't implement them, and some (namely lighttpd/1.4.19,
+    // running on openstreetmap.org at time of writing) return
+    // a '417 Expectance Failure' response on getting that.
+    {
+        if ( ! _customHeaders ) {
+            // Initialize only once
+            _customHeaders = curl_slist_append(_customHeaders, "Expect:");
+        }
+        ccode = curl_easy_setopt(_handle, CURLOPT_HTTPHEADER, _customHeaders);
+        if ( ccode != CURLE_OK ) {
+            throw gnash::GnashException(curl_easy_strerror(ccode));
+        }
+    }
+
+
+
        CURLMcode mcode = curl_multi_add_handle(_mhandle, _handle);
        if ( mcode != CURLM_OK ) {
                throw gnash::GnashException(curl_multi_strerror(mcode));
@@ -974,6 +994,7 @@
        curl_easy_cleanup(_handle);
        curl_multi_cleanup(_mhandle);
        std::fclose(_cache);
+    if ( _customHeaders ) curl_slist_free_all(_customHeaders); 
 }
 
 /*public*/


reply via email to

[Prev in Thread] Current Thread [Next in Thread]