From: Chad Horohoe Date: Thu, 8 Jan 2009 06:56:11 +0000 (+0000) Subject: Fix odd edge case for POST Http::request()'s. I incidentally found this while working... X-Git-Tag: 1.31.0-rc.0~43502 X-Git-Url: https://git.cyclocoop.org/%27.%24link.%27?a=commitdiff_plain;h=7b8b26aa6493c53145b295e796b5e528c65cf0e2;p=lhc%2Fweb%2Fwiklou.git Fix odd edge case for POST Http::request()'s. I incidentally found this while working with Special:Import. For some reason that I can't 100% nail down--works fine on Win32, fails on CentOS--cURL seems to want CURLOPT_POSTFIELDS set to at least an empty string, if not values. Using a workaround I found, we'll set it to an empty string if we're making a POST. Since we explicitly allow setting of arbitrary curlopts later, users can still override the empty string if they in fact want to set this. This fixes my Special:Import problem (and possibly similar issues) and has no regressions afaict. Credit to Phill Sparks @ milk-hub.net/blog/2008/08/26/curl_error_26#comments-77 --- diff --git a/includes/HttpFunctions.php b/includes/HttpFunctions.php index 245806966d..269d45ff2f 100644 --- a/includes/HttpFunctions.php +++ b/includes/HttpFunctions.php @@ -56,8 +56,10 @@ class Http { curl_setopt( $c, CURLOPT_TIMEOUT, $timeout ); curl_setopt( $c, CURLOPT_USERAGENT, self :: userAgent() ); - if ( $method == 'POST' ) + if ( $method == 'POST' ) { curl_setopt( $c, CURLOPT_POST, true ); + curl_setopt( $c, CURLOPT_POSTFIELDS, '' ); + } else curl_setopt( $c, CURLOPT_CUSTOMREQUEST, $method );