From 7b8b26aa6493c53145b295e796b5e528c65cf0e2 Mon Sep 17 00:00:00 2001 From: Chad Horohoe Date: Thu, 8 Jan 2009 06:56:11 +0000 Subject: [PATCH] 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 @ http://www.milk-hub.net/blog/2008/08/26/curl_error_26#comments-77 --- includes/HttpFunctions.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 ); -- 2.20.1