Ticket #8787: 8787.diff

File 8787.diff, 2.6 KB (added by jacobsantos, 3 years ago)

Some documentation and the other fix.

  • http.php

     
    257257                } 
    258258 
    259259                if ( is_null($r['body']) ) { 
     260                        // Some servers fail when sending content without the content-length 
     261                        // header being set. 
    260262                        $r['headers']['Content-Length'] = 0; 
    261263                        $transports = WP_Http::_getTransport($r); 
    262264                } else { 
     
    660662                if ( false === $arrURL ) 
    661663                        return new WP_Error('http_request_failed', sprintf(__('Malformed URL: %s'), $url)); 
    662664 
    663                 if ( 'http' != $arrURL['scheme'] || 'https' != $arrURL['scheme'] ) 
     665                if ( 'http' != $arrURL['scheme'] && 'https' != $arrURL['scheme'] ) 
    664666                        $url = str_replace($arrURL['scheme'], 'http', $url); 
    665667 
    666668                if ( !defined('WP_DEBUG') || ( defined('WP_DEBUG') && false === WP_DEBUG ) ) 
     
    794796 
    795797                $context = stream_context_create($arrContext); 
    796798 
    797                 if ( !defined('WP_DEBUG') || ( defined('WP_DEBUG') && false === WP_DEBUG ) ) 
     799                if ( ! defined('WP_DEBUG') || ( defined('WP_DEBUG') && false === WP_DEBUG ) ) 
    798800                        $handle = @fopen($url, 'r', false, $context); 
    799801                else 
    800802                        $handle = fopen($url, 'r', false, $context); 
     
    9991001                        unset($r['headers']['user-agent']); 
    10001002                } 
    10011003 
    1002                 // If timeout is a float less than 1, round it up to 1. 
     1004                // cURL extension will sometimes fail when the timeout is less than 1 as 
     1005                // it may round down to 0, which gives it unlimited timeout. 
    10031006                if ( $r['timeout'] > 0 && $r['timeout'] < 1 ) 
    10041007                        $r['timeout'] = 1; 
    10051008 
    10061009                $handle = curl_init(); 
    10071010                curl_setopt( $handle, CURLOPT_URL, $url); 
    10081011 
     1012                // The cURL extension requires that the option be set for the HEAD to 
     1013                // work properly. 
    10091014                if ( 'HEAD' === $r['method'] ) { 
    10101015                        curl_setopt( $handle, CURLOPT_NOBODY, true ); 
    10111016                } 
     
    10241029                curl_setopt( $handle, CURLOPT_TIMEOUT, $r['timeout'] ); 
    10251030                curl_setopt( $handle, CURLOPT_MAXREDIRS, $r['redirection'] ); 
    10261031 
     1032                // The option doesn't work with safe mode or when open_basedir is set. 
    10271033                if ( !ini_get('safe_mode') && !ini_get('open_basedir') ) 
    10281034                        curl_setopt( $handle, CURLOPT_FOLLOWLOCATION, true ); 
    10291035 
     
    10351041                else 
    10361042                        curl_setopt( $handle, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1 ); 
    10371043 
     1044                // Cookies are not handled by the HTTP API currently. Allow for plugin 
     1045                // authors to handle it themselves... Although, it is somewhat pointless 
     1046                // without some reference. 
    10381047                do_action_ref_array( 'http_api_curl', array(&$handle) ); 
    10391048 
     1049                // We don't need to return the body, so don't. Just execution request 
     1050                // and return. 
    10401051                if ( ! $r['blocking'] ) { 
    10411052                        curl_exec( $handle ); 
    10421053                        curl_close( $handle );