[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] /srv/bzr/gnash/trunk r10425: Don't override user-defined
From: |
Sandro Santilli |
Subject: |
[Gnash-commit] /srv/bzr/gnash/trunk r10425: Don't override user-defined custom headers for the sake of "Expect:" stripping. |
Date: |
Sun, 14 Dec 2008 15:15:04 +0100 |
User-agent: |
Bazaar (1.5) |
------------------------------------------------------------
revno: 10425
committer: Sandro Santilli <address@hidden>
branch nick: trunk
timestamp: Sun 2008-12-14 15:15:04 +0100
message:
Don't override user-defined custom headers for the sake of "Expect:"
stripping.
Instead, merge the user-defined and our own, letting user overrid Expect if
she's willing to.
Also, fix leakage of user-defined headers.
modified:
libbase/curl_adapter.cpp
=== modified file 'libbase/curl_adapter.cpp'
--- a/libbase/curl_adapter.cpp 2008-12-14 12:44:29 +0000
+++ b/libbase/curl_adapter.cpp 2008-12-14 14:15:04 +0000
@@ -909,15 +909,11 @@
// 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));
- }
+ assert ( ! _customHeaders );
+ _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);
@@ -932,9 +928,20 @@
{
log_debug("CurlStreamFile %p created", this);
init(url);
-
- curl_slist *headerList = 0;
-
+
+ _postdata = vars;
+
+ // 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.
+ //
+ // Do this before adding user-requested headers so user
+ // specified ones take precedence
+ //
+ assert ( ! _customHeaders );
+ _customHeaders = curl_slist_append(_customHeaders, "Expect:");
+
for (NetworkAdapter::RequestHeaders::const_iterator i = headers.begin(),
e = headers.end(); i != e; ++i)
{
@@ -942,17 +949,16 @@
if (!NetworkAdapter::isHeaderAllowed(i->first)) continue;
std::ostringstream os;
os << i->first << ": " << i->second;
- headerList = curl_slist_append(headerList, os.str().c_str());
+ _customHeaders = curl_slist_append(_customHeaders, os.str().c_str());
}
- curl_easy_setopt(_handle, CURLOPT_HTTPHEADER, headerList);
-
-// curl_slist_free_all(headerList);
-
- _postdata = vars;
-
CURLcode ccode;
+ ccode = curl_easy_setopt(_handle, CURLOPT_HTTPHEADER, _customHeaders);
+ if ( ccode != CURLE_OK ) {
+ throw gnash::GnashException(curl_easy_strerror(ccode));
+ }
+
ccode = curl_easy_setopt(_handle, CURLOPT_POST, 1);
if ( ccode != CURLE_OK ) {
throw gnash::GnashException(curl_easy_strerror(ccode));
@@ -976,21 +982,6 @@
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));
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] /srv/bzr/gnash/trunk r10425: Don't override user-defined custom headers for the sake of "Expect:" stripping.,
Sandro Santilli <=