WordPress.org

Make WordPress Core


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/http.php

    r10321 r10150  
    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;
    248245            $transports = WP_Http::_getTransport($r);
    249246        } else {
     
    394391     *
    395392     * @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.
    397394     */
    398395    function chunkTransferDecode($body) {
     
    405402        //$parsedHeaders = array(); Unsupported
    406403
    407         while ( true ) {
     404        $done = false;
     405
     406        do {
    408407            $hasChunk = (bool) preg_match( '/^([0-9a-f]+)(\s|\n)+/mi', $body, $match );
    409408
    410409            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                }
    413413
    414414                $length = hexdec( $match[1] );
     
    420420                $body = ltrim(str_replace(array($match[0], $strBody), '', $body), "\n");
    421421
    422                 if( "0" == trim($body) )
     422                if( "0" == trim($body) ) {
     423                    $done = true;
    423424                    return $parsedBody; // Ignore footer headers.
     425                    break;
     426                }
    424427            } else {
    425                 return $body;
     428                return new WP_Error('http_chunked_decode', __('Does not appear to be chunked encoded or body is malformed.') );
    426429            }
    427         }
     430        } while ( false === $done );
    428431    }
    429432}
     
    642645            return new WP_Error('http_request_failed', sprintf(__('Malformed URL: %s'), $url));
    643646
    644         if ( 'http' != $arrURL['scheme'] && 'https' != $arrURL['scheme'] )
     647        if ( 'http' != $arrURL['scheme'] || 'https' != $arrURL['scheme'] )
    645648            $url = str_replace($arrURL['scheme'], 'http', $url);
    646649
     
    748751            return new WP_Error('http_request_failed', sprintf(__('Malformed URL: %s'), $url));
    749752
    750         if ( 'http' != $arrURL['scheme'] && 'https' != $arrURL['scheme'] )
     753        if ( 'http' != $arrURL['scheme'] || 'https' != $arrURL['scheme'] )
    751754            $url = str_replace($arrURL['scheme'], 'http', $url);
    752755
     
    775778        $context = stream_context_create($arrContext);
    776779
    777         if ( ! defined('WP_DEBUG') || ( defined('WP_DEBUG') && false === WP_DEBUG ) )
     780        if ( !defined('WP_DEBUG') || ( defined('WP_DEBUG') && false === WP_DEBUG ) )
    778781            $handle = @fopen($url, 'r', false, $context);
    779782        else
     
    980983        }
    981984
    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.
    984986        if ( $r['timeout'] > 0 && $r['timeout'] < 1 )
    985987            $r['timeout'] = 1;
     
    988990        curl_setopt( $handle, CURLOPT_URL, $url);
    989991
    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.
    10111010        if ( !ini_get('safe_mode') && !ini_get('open_basedir') )
    10121011            curl_setopt( $handle, CURLOPT_FOLLOWLOCATION, true );
     
    10641063     */
    10651064    function test() {
    1066         if ( function_exists('curl_init') && function_exists('curl_exec') )
     1065        if ( function_exists('curl_init') )
    10671066            return true;
    10681067
Note: See TracChangeset for help on using the changeset viewer.