Make WordPress Core

Changeset 10320


Ignore:
Timestamp:
01/06/2009 05:29:24 PM (15 years ago)
Author:
ryan
Message:

Fix URL checking and add phpdoc. Props jacobsantos. fixes #8787 for trunk

File:
1 edited

Legend:

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

    r10309 r10320  
    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);
     
    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
     
    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
     
    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;
     
    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 );
     
    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 );
     
    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 );
Note: See TracChangeset for help on using the changeset viewer.