Fix raw_response code in Streams transport. Props jacobsantos. fixes #8476
git-svn-id: https://develop.svn.wordpress.org/trunk@10117 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
1d11d269e3
commit
9a7e2fc242
@ -396,7 +396,7 @@ class WP_Http {
|
|||||||
$body = str_replace(array("\r\n", "\r"), "\n", $body);
|
$body = str_replace(array("\r\n", "\r"), "\n", $body);
|
||||||
// The body is not chunked encoding or is malformed.
|
// The body is not chunked encoding or is malformed.
|
||||||
if ( ! preg_match( '/^[0-9a-f]+(\s|\n)+/mi', trim($body) ) )
|
if ( ! preg_match( '/^[0-9a-f]+(\s|\n)+/mi', trim($body) ) )
|
||||||
return false;
|
return $body;
|
||||||
|
|
||||||
$parsedBody = '';
|
$parsedBody = '';
|
||||||
//$parsedHeaders = array(); Unsupported
|
//$parsedHeaders = array(); Unsupported
|
||||||
@ -672,7 +672,11 @@ class WP_Http_Fopen {
|
|||||||
if ( function_exists('stream_get_meta_data') ) {
|
if ( function_exists('stream_get_meta_data') ) {
|
||||||
$meta = stream_get_meta_data($handle);
|
$meta = stream_get_meta_data($handle);
|
||||||
$theHeaders = $meta['wrapper_data'];
|
$theHeaders = $meta['wrapper_data'];
|
||||||
|
if( isset( $meta['wrapper_data']['headers'] ) )
|
||||||
|
$theHeaders = $meta['wrapper_data']['headers'];
|
||||||
} else {
|
} else {
|
||||||
|
if( ! isset( $http_response_header ) )
|
||||||
|
global $http_response_header;
|
||||||
$theHeaders = $http_response_header;
|
$theHeaders = $http_response_header;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -793,7 +797,12 @@ class WP_Http_Streams {
|
|||||||
|
|
||||||
$strResponse = stream_get_contents($handle);
|
$strResponse = stream_get_contents($handle);
|
||||||
$meta = stream_get_meta_data($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'] )
|
if ( ! empty( $strResponse ) && isset( $processedHeaders['headers']['transfer-encoding'] ) && 'chunked' == $processedHeaders['headers']['transfer-encoding'] )
|
||||||
$strResponse = WP_Http::chunkTransferDecode($strResponse);
|
$strResponse = WP_Http::chunkTransferDecode($strResponse);
|
||||||
@ -1031,7 +1040,7 @@ class WP_Http_Curl {
|
|||||||
return new WP_Error('http_request_failed', $curl_error);
|
return new WP_Error('http_request_failed', $curl_error);
|
||||||
if ( in_array( curl_getinfo( $handle, CURLINFO_HTTP_CODE ), array(301, 302) ) )
|
if ( in_array( curl_getinfo( $handle, CURLINFO_HTTP_CODE ), array(301, 302) ) )
|
||||||
return new WP_Error('http_request_failed', __('Too many redirects.'));
|
return new WP_Error('http_request_failed', __('Too many redirects.'));
|
||||||
|
|
||||||
$theHeaders = array( 'headers' => array() );
|
$theHeaders = array( 'headers' => array() );
|
||||||
$theBody = '';
|
$theBody = '';
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user