Fixes process headers for fopen header return, fixes HTTP extension response array. Props santosj. see #4779
git-svn-id: https://develop.svn.wordpress.org/trunk@8523 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
b7d7804240
commit
4caa408fac
|
@ -313,14 +313,9 @@ class WP_Http {
|
||||||
/**
|
/**
|
||||||
* Transform header string into an array.
|
* Transform header string into an array.
|
||||||
*
|
*
|
||||||
* If an array is given, then it will be immediately passed through with no
|
* If an array is given then it is assumed to be raw header data with
|
||||||
* changes. This is to prevent overhead in processing headers that don't
|
* numeric keys with the headers as the values. No headers must be passed
|
||||||
* need to be processed. That and it is unknown what kind of effect
|
* that were already processed.
|
||||||
* processing the array will have since there is no checking done on whether
|
|
||||||
* ':' does not exist within the array string.
|
|
||||||
*
|
|
||||||
* Checking could be added, but it is easier and faster to just passed the
|
|
||||||
* array through and assume that it has already been processed.
|
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
* @static
|
* @static
|
||||||
|
@ -330,10 +325,8 @@ class WP_Http {
|
||||||
* @return array Processed string headers
|
* @return array Processed string headers
|
||||||
*/
|
*/
|
||||||
function processHeaders($headers) {
|
function processHeaders($headers) {
|
||||||
if ( is_array($headers) )
|
if ( is_string($headers) )
|
||||||
return $headers;
|
$headers = explode("\n", str_replace(array("\r\n", "\r"), "\n", $headers) );
|
||||||
|
|
||||||
$headers = explode("\n", str_replace(array("\r\n", "\r"), "\n", $headers) );
|
|
||||||
|
|
||||||
$response = array('code' => 0, 'message' => '');
|
$response = array('code' => 0, 'message' => '');
|
||||||
|
|
||||||
|
@ -342,6 +335,7 @@ class WP_Http {
|
||||||
if ( empty($tempheader) )
|
if ( empty($tempheader) )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|
||||||
if ( false === strpos($tempheader, ':') ) {
|
if ( false === strpos($tempheader, ':') ) {
|
||||||
list( , $iResponseCode, $strResponseMsg) = explode(' ', $tempheader, 3);
|
list( , $iResponseCode, $strResponseMsg) = explode(' ', $tempheader, 3);
|
||||||
$response['code'] = $iResponseCode;
|
$response['code'] = $iResponseCode;
|
||||||
|
@ -560,9 +554,11 @@ class WP_Http_Fopen {
|
||||||
} else {
|
} else {
|
||||||
$theHeaders = $http_response_header;
|
$theHeaders = $http_response_header;
|
||||||
}
|
}
|
||||||
$processedHeaders = WP_Http::processHeaders($theHeaders);
|
|
||||||
|
|
||||||
fclose($handle);
|
fclose($handle);
|
||||||
|
|
||||||
|
$processedHeaders = WP_Http::processHeaders($theHeaders);
|
||||||
|
|
||||||
return array('headers' => $processedHeaders['headers'], 'body' => $strResponse, 'response' => $processedHeaders['response']);
|
return array('headers' => $processedHeaders['headers'], 'body' => $strResponse, 'response' => $processedHeaders['response']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -762,8 +758,8 @@ class WP_Http_ExtHTTP {
|
||||||
$theHeaders = WP_Http::processHeaders($theHeaders);
|
$theHeaders = WP_Http::processHeaders($theHeaders);
|
||||||
|
|
||||||
$theResponse = array();
|
$theResponse = array();
|
||||||
$theResponse['response']['code'] = $info['response_code'];
|
$theResponse['code'] = $info['response_code'];
|
||||||
$theResponse['response']['message'] = get_status_header_desc($info['response_code']);
|
$theResponse['message'] = get_status_header_desc($info['response_code']);
|
||||||
|
|
||||||
return array('headers' => $theHeaders['headers'], 'body' => $theBody, 'response' => $theResponse);
|
return array('headers' => $theHeaders['headers'], 'body' => $theBody, 'response' => $theResponse);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue