mirror of
https://github.com/WordPress/WordPress.git
synced 2025-03-31 04:18:29 +00:00
Avoid notices for requests with no body. Also fixes a few race conditions related to headers. Fixes #11872
git-svn-id: http://svn.automattic.com/wordpress/trunk@13849 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
5a42dae784
commit
c0974fb518
@ -392,8 +392,9 @@ class WP_Http {
|
|||||||
* @return array Array with 'headers' and 'body' keys.
|
* @return array Array with 'headers' and 'body' keys.
|
||||||
*/
|
*/
|
||||||
function processResponse($strResponse) {
|
function processResponse($strResponse) {
|
||||||
list($theHeaders, $theBody) = explode("\r\n\r\n", $strResponse, 2);
|
$res = explode("\r\n\r\n", $strResponse, 2);
|
||||||
return array('headers' => $theHeaders, 'body' => $theBody);
|
|
||||||
|
return array('headers' => isset($res[0]) ? $res[0] : array(), 'body' => isset($res[1]) ? $res[1] : '');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -426,7 +427,7 @@ class WP_Http {
|
|||||||
// If a redirection has taken place, The headers for each page request may have been passed.
|
// If a redirection has taken place, The headers for each page request may have been passed.
|
||||||
// In this case, determine the final HTTP header and parse from there.
|
// In this case, determine the final HTTP header and parse from there.
|
||||||
for ( $i = count($headers)-1; $i >= 0; $i-- ) {
|
for ( $i = count($headers)-1; $i >= 0; $i-- ) {
|
||||||
if ( false === strpos($headers[$i], ':') ) {
|
if ( !empty($headers[$i]) && false === strpos($headers[$i], ':') ) {
|
||||||
$headers = array_splice($headers, $i);
|
$headers = array_splice($headers, $i);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -439,9 +440,7 @@ class WP_Http {
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
if ( false === strpos($tempheader, ':') ) {
|
if ( false === strpos($tempheader, ':') ) {
|
||||||
list( , $iResponseCode, $strResponseMsg) = explode(' ', $tempheader, 3);
|
list( , $response['code'], $response['message']) = explode(' ', $tempheader, 3);
|
||||||
$response['code'] = $iResponseCode;
|
|
||||||
$response['message'] = $strResponseMsg;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1228,7 +1227,11 @@ class WP_Http_ExtHTTP {
|
|||||||
if ( ! $r['blocking'] )
|
if ( ! $r['blocking'] )
|
||||||
return array( 'headers' => array(), 'body' => '', 'response' => array('code' => false, 'message' => false), 'cookies' => array() );
|
return array( 'headers' => array(), 'body' => '', 'response' => array('code' => false, 'message' => false), 'cookies' => array() );
|
||||||
|
|
||||||
list($theHeaders, $theBody) = explode("\r\n\r\n", $strResponse, 2);
|
$headers_body = WP_HTTP::processResponse($strResponse);
|
||||||
|
$theHeaders = $headers_body['headers'];
|
||||||
|
$theBody = $headers_body['body'];
|
||||||
|
unset($headers_body);
|
||||||
|
|
||||||
$theHeaders = WP_Http::processHeaders($theHeaders);
|
$theHeaders = WP_Http::processHeaders($theHeaders);
|
||||||
|
|
||||||
if ( ! empty( $theBody ) && isset( $theHeaders['headers']['transfer-encoding'] ) && 'chunked' == $theHeaders['headers']['transfer-encoding'] ) {
|
if ( ! empty( $theBody ) && isset( $theHeaders['headers']['transfer-encoding'] ) && 'chunked' == $theHeaders['headers']['transfer-encoding'] ) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user