Changes from trunk/wp-includes/http.php at r10150 to branches/2.7/wp-includes/http.php at r10321
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.7/wp-includes/http.php
r10150 r10321 243 243 244 244 if ( is_null($r['body']) ) { 245 // Some servers fail when sending content without the content-length 246 // header being set. 247 $r['headers']['Content-Length'] = 0; 245 248 $transports = WP_Http::_getTransport($r); 246 249 } else { … … 391 394 * 392 395 * @param string $body Body content 393 * @return bool|string|WP_Error False if not chunked encoded. WP_Error on failure. Chunked decoded body on success.396 * @return string Chunked decoded body on success or raw body on failure. 394 397 */ 395 398 function chunkTransferDecode($body) { … … 402 405 //$parsedHeaders = array(); Unsupported 403 406 404 $done = false; 405 406 do { 407 while ( true ) { 407 408 $hasChunk = (bool) preg_match( '/^([0-9a-f]+)(\s|\n)+/mi', $body, $match ); 408 409 409 410 if ( $hasChunk ) { 410 if ( empty($match[1]) ) { 411 return new WP_Error('http_chunked_decode', __('Does not appear to be chunked encoded or body is malformed.') ); 412 } 411 if ( empty($match[1]) ) 412 return $body; 413 413 414 414 $length = hexdec( $match[1] ); … … 420 420 $body = ltrim(str_replace(array($match[0], $strBody), '', $body), "\n"); 421 421 422 if( "0" == trim($body) ) { 423 $done = true; 422 if( "0" == trim($body) ) 424 423 return $parsedBody; // Ignore footer headers. 425 break;426 }427 424 } else { 428 return new WP_Error('http_chunked_decode', __('Does not appear to be chunked encoded or body is malformed.') );425 return $body; 429 426 } 430 } while ( false === $done );427 } 431 428 } 432 429 } … … 645 642 return new WP_Error('http_request_failed', sprintf(__('Malformed URL: %s'), $url)); 646 643 647 if ( 'http' != $arrURL['scheme'] ||'https' != $arrURL['scheme'] )644 if ( 'http' != $arrURL['scheme'] && 'https' != $arrURL['scheme'] ) 648 645 $url = str_replace($arrURL['scheme'], 'http', $url); 649 646 … … 751 748 return new WP_Error('http_request_failed', sprintf(__('Malformed URL: %s'), $url)); 752 749 753 if ( 'http' != $arrURL['scheme'] ||'https' != $arrURL['scheme'] )750 if ( 'http' != $arrURL['scheme'] && 'https' != $arrURL['scheme'] ) 754 751 $url = str_replace($arrURL['scheme'], 'http', $url); 755 752 … … 778 775 $context = stream_context_create($arrContext); 779 776 780 if ( ! defined('WP_DEBUG') || ( defined('WP_DEBUG') && false === WP_DEBUG ) )777 if ( ! defined('WP_DEBUG') || ( defined('WP_DEBUG') && false === WP_DEBUG ) ) 781 778 $handle = @fopen($url, 'r', false, $context); 782 779 else … … 983 980 } 984 981 985 // If timeout is a float less than 1, round it up to 1. 982 // cURL extension will sometimes fail when the timeout is less than 1 as 983 // it may round down to 0, which gives it unlimited timeout. 986 984 if ( $r['timeout'] > 0 && $r['timeout'] < 1 ) 987 985 $r['timeout'] = 1; … … 990 988 curl_setopt( $handle, CURLOPT_URL, $url); 991 989 990 // The cURL extension requires that the option be set for the HEAD to 991 // work properly. 992 992 if ( 'HEAD' === $r['method'] ) { 993 993 curl_setopt( $handle, CURLOPT_NOBODY, true ); … … 1008 1008 curl_setopt( $handle, CURLOPT_MAXREDIRS, $r['redirection'] ); 1009 1009 1010 // The option doesn't work with safe mode or when open_basedir is set. 1010 1011 if ( !ini_get('safe_mode') && !ini_get('open_basedir') ) 1011 1012 curl_setopt( $handle, CURLOPT_FOLLOWLOCATION, true ); … … 1063 1064 */ 1064 1065 function test() { 1065 if ( function_exists('curl_init') )1066 if ( function_exists('curl_init') && function_exists('curl_exec') ) 1066 1067 return true; 1067 1068
Note: See TracChangeset
for help on using the changeset viewer.