Make WordPress Core


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.7/wp-includes/http.php

    r10150 r10321  
    243243
    244244        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;
    245248            $transports = WP_Http::_getTransport($r);
    246249        } else {
     
    391394     *
    392395     * @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.
    394397     */
    395398    function chunkTransferDecode($body) {
     
    402405        //$parsedHeaders = array(); Unsupported
    403406
    404         $done = false;
    405 
    406         do {
     407        while ( true ) {
    407408            $hasChunk = (bool) preg_match( '/^([0-9a-f]+)(\s|\n)+/mi', $body, $match );
    408409
    409410            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;
    413413
    414414                $length = hexdec( $match[1] );
     
    420420                $body = ltrim(str_replace(array($match[0], $strBody), '', $body), "\n");
    421421
    422                 if( "0" == trim($body) ) {
    423                     $done = true;
     422                if( "0" == trim($body) )
    424423                    return $parsedBody; // Ignore footer headers.
    425                     break;
    426                 }
    427424            } else {
    428                 return new WP_Error('http_chunked_decode', __('Does not appear to be chunked encoded or body is malformed.') );
     425                return $body;
    429426            }
    430         } while ( false === $done );
     427        }
    431428    }
    432429}
     
    645642            return new WP_Error('http_request_failed', sprintf(__('Malformed URL: %s'), $url));
    646643
    647         if ( 'http' != $arrURL['scheme'] || 'https' != $arrURL['scheme'] )
     644        if ( 'http' != $arrURL['scheme'] && 'https' != $arrURL['scheme'] )
    648645            $url = str_replace($arrURL['scheme'], 'http', $url);
    649646
     
    751748            return new WP_Error('http_request_failed', sprintf(__('Malformed URL: %s'), $url));
    752749
    753         if ( 'http' != $arrURL['scheme'] || 'https' != $arrURL['scheme'] )
     750        if ( 'http' != $arrURL['scheme'] && 'https' != $arrURL['scheme'] )
    754751            $url = str_replace($arrURL['scheme'], 'http', $url);
    755752
     
    778775        $context = stream_context_create($arrContext);
    779776
    780         if ( !defined('WP_DEBUG') || ( defined('WP_DEBUG') && false === WP_DEBUG ) )
     777        if ( ! defined('WP_DEBUG') || ( defined('WP_DEBUG') && false === WP_DEBUG ) )
    781778            $handle = @fopen($url, 'r', false, $context);
    782779        else
     
    983980        }
    984981
    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.
    986984        if ( $r['timeout'] > 0 && $r['timeout'] < 1 )
    987985            $r['timeout'] = 1;
     
    990988        curl_setopt( $handle, CURLOPT_URL, $url);
    991989
     990        // The cURL extension requires that the option be set for the HEAD to
     991        // work properly.
    992992        if ( 'HEAD' === $r['method'] ) {
    993993            curl_setopt( $handle, CURLOPT_NOBODY, true );
     
    10081008        curl_setopt( $handle, CURLOPT_MAXREDIRS, $r['redirection'] );
    10091009
     1010        // The option doesn't work with safe mode or when open_basedir is set.
    10101011        if ( !ini_get('safe_mode') && !ini_get('open_basedir') )
    10111012            curl_setopt( $handle, CURLOPT_FOLLOWLOCATION, true );
     
    10631064     */
    10641065    function test() {
    1065         if ( function_exists('curl_init') )
     1066        if ( function_exists('curl_init') && function_exists('curl_exec') )
    10661067            return true;
    10671068
Note: See TracChangeset for help on using the changeset viewer.