Correctly set the body on Curl requests with an empty body. Add a defensive check to WP_Http_Encoding::decompress to prevent the decompression functions running on empty strings. Fixes #11912

git-svn-id: http://svn.automattic.com/wordpress/trunk@12739 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
dd32 2010-01-16 23:11:28 +00:00
parent 795ce48b83
commit e85a09e8e9
1 changed files with 7 additions and 1 deletions

View File

@ -1360,7 +1360,10 @@ class WP_Http_Curl {
if ( !empty($theResponse) ) {
$headerLength = curl_getinfo($handle, CURLINFO_HEADER_SIZE);
$theHeaders = trim( substr($theResponse, 0, $headerLength) );
$theBody = substr( $theResponse, $headerLength );
if ( strlen($theResponse) > $headerLength )
$theBody = substr( $theResponse, $headerLength );
else
$theBody = '';
if ( false !== strrpos($theHeaders, "\r\n\r\n") ) {
$headerParts = explode("\r\n\r\n", $theHeaders);
$theHeaders = $headerParts[ count($headerParts) -1 ];
@ -1817,6 +1820,9 @@ class WP_Http_Encoding {
*/
function decompress( $compressed, $length = null ) {
if ( empty($compressed) )
return $compressed;
if ( false !== ( $decompressed = @gzinflate( $compressed ) ) )
return $decompressed;