From 5382d2b80e4ba0ff9ac0ac70812cde40d4f070ae Mon Sep 17 00:00:00 2001 From: ryan Date: Sun, 7 Dec 2008 20:30:59 +0000 Subject: [PATCH] Fix raw_response code in Streams transport. Props jacobsantos. fixes #8476 git-svn-id: http://svn.automattic.com/wordpress/trunk@10117 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/http.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/wp-includes/http.php b/wp-includes/http.php index 60c2e968a9..434a4ff932 100644 --- a/wp-includes/http.php +++ b/wp-includes/http.php @@ -396,7 +396,7 @@ class WP_Http { $body = str_replace(array("\r\n", "\r"), "\n", $body); // The body is not chunked encoding or is malformed. if ( ! preg_match( '/^[0-9a-f]+(\s|\n)+/mi', trim($body) ) ) - return false; + return $body; $parsedBody = ''; //$parsedHeaders = array(); Unsupported @@ -672,7 +672,11 @@ class WP_Http_Fopen { if ( function_exists('stream_get_meta_data') ) { $meta = stream_get_meta_data($handle); $theHeaders = $meta['wrapper_data']; + if( isset( $meta['wrapper_data']['headers'] ) ) + $theHeaders = $meta['wrapper_data']['headers']; } else { + if( ! isset( $http_response_header ) ) + global $http_response_header; $theHeaders = $http_response_header; } @@ -793,7 +797,12 @@ class WP_Http_Streams { $strResponse = stream_get_contents($handle); $meta = stream_get_meta_data($handle); - $processedHeaders = WP_Http::processHeaders($meta['wrapper_data']); + + $processedHeaders = array(); + if( isset( $meta['wrapper_data']['headers'] ) ) + $processedHeaders = WP_Http::processHeaders($meta['wrapper_data']['headers']); + else + $processedHeaders = WP_Http::processHeaders($meta['wrapper_data']); if ( ! empty( $strResponse ) && isset( $processedHeaders['headers']['transfer-encoding'] ) && 'chunked' == $processedHeaders['headers']['transfer-encoding'] ) $strResponse = WP_Http::chunkTransferDecode($strResponse); @@ -1031,7 +1040,7 @@ class WP_Http_Curl { return new WP_Error('http_request_failed', $curl_error); if ( in_array( curl_getinfo( $handle, CURLINFO_HTTP_CODE ), array(301, 302) ) ) return new WP_Error('http_request_failed', __('Too many redirects.')); - + $theHeaders = array( 'headers' => array() ); $theBody = ''; }