Make WordPress Core

Changeset 10321


Ignore:
Timestamp:
01/06/2009 05:30:41 PM (18 years ago)
Author:
ryan
Message:

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

File:
1 edited

Legend:

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

    r10310 r10321  
    243243
    244244                if ( is_null($r['body']) ) {
     245                        // Some servers fail when sending content without the content-length
     246                        // header being set.
    245247                        $r['headers']['Content-Length'] = 0;
    246248                        $transports = WP_Http::_getTransport($r);
     
    640642                        return new WP_Error('http_request_failed', sprintf(__('Malformed URL: %s'), $url));
    641643
    642                 if ( 'http' != $arrURL['scheme'] || 'https' != $arrURL['scheme'] )
     644                if ( 'http' != $arrURL['scheme'] && 'https' != $arrURL['scheme'] )
    643645                        $url = str_replace($arrURL['scheme'], 'http', $url);
    644646
     
    773775                $context = stream_context_create($arrContext);
    774776
    775                 if ( !defined('WP_DEBUG') || ( defined('WP_DEBUG') && false === WP_DEBUG ) )
     777                if ( ! defined('WP_DEBUG') || ( defined('WP_DEBUG') && false === WP_DEBUG ) )
    776778                        $handle = @fopen($url, 'r', false, $context);
    777779                else
     
    978980                }
    979981
    980                 // 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.
    981984                if ( $r['timeout'] > 0 && $r['timeout'] < 1 )
    982985                        $r['timeout'] = 1;
     
    985988                curl_setopt( $handle, CURLOPT_URL, $url);
    986989
     990                // The cURL extension requires that the option be set for the HEAD to
     991                // work properly.
    987992                if ( 'HEAD' === $r['method'] ) {
    988993                        curl_setopt( $handle, CURLOPT_NOBODY, true );
     
    10031008                curl_setopt( $handle, CURLOPT_MAXREDIRS, $r['redirection'] );
    10041009
     1010                // The option doesn't work with safe mode or when open_basedir is set.
    10051011                if ( !ini_get('safe_mode') && !ini_get('open_basedir') )
    10061012                        curl_setopt( $handle, CURLOPT_FOLLOWLOCATION, true );
Note: See TracChangeset for help on using the changeset viewer.