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