Make WordPress Core

Ticket #4779: 4779.formatting+phpdoc.2.diff

File 4779.formatting+phpdoc.2.diff, 26.6 KB (added by DD32, 16 years ago)
  • wp-includes/http.php

     
    44 *
    55 * @package WordPress
    66 * @subpackage HTTP
    7  * @since {@internal Version Unknown}}
     7 * @since 2.7
    88 * @author Jacob Santos <wordpress@santosj.name>
    99 */
    1010
     
    1616 *
    1717 * @package WordPress
    1818 * @subpackage HTTP
    19  * @since {@internal Version Unknown}}
     19 * @since 2.7
    2020 */
    21 class WP_Http
    22 {
     21class WP_Http {
    2322
    2423        /**
    2524         * PHP4 style Constructor - Calls PHP5 Style Constructor
    2625         *
    27          * @since {@internal Version Unknown}}
     26         * @since 2.7
    2827         * @return WP_Http
    2928         */
    30         function WP_Http()
    31         {
     29        function WP_Http() {
    3230                $this->__construct();
    3331        }
    3432
    3533        /**
    3634         * PHP5 style Constructor - Setup available transport if not available.
    3735         *
    38          * @since {@internal Version Unknown}}
     36         * @since 2.7
    3937         * @return WP_Http
    4038         */
    41         function __construct()
    42         {
     39        function __construct() {
    4340                WP_Http::_getTransport();
    4441        }
    4542
     
    4946         * Tests all of the objects and returns the object that passes. Also caches
    5047         * that object to be used later.
    5148         *
    52          * @since {@internal Version Unknown}}
     49         * @since 2.7
    5350         * @access private
    5451         *
    5552         * @return object|null Null if no transports are available, HTTP transport object.
    5653         */
    57         function &_getTransport()
    58         {
     54        function &_getTransport() {
    5955                static $working_transport;
    6056
    61                 if( is_null($working_transport) ) {
    62                         if( true === WP_Http_Streams::test() )
     57                if ( is_null($working_transport) ) {
     58                        if ( true === WP_Http_Streams::test() )
    6359                                $working_transport = new WP_Http_Streams();
    64                         else if( true === WP_Http_ExtHttp::test() )
     60                        else if ( true === WP_Http_ExtHttp::test() )
    6561                                $working_transport = new WP_Http_ExtHttp();
    66                         else if( true === WP_Http_Fopen::test() )
     62                        else if ( true === WP_Http_Fopen::test() )
    6763                                $working_transport = new WP_Http_Fopen();
    68                         else if( true === WP_Http_Fsockopen::test() )
     64                        else if ( true === WP_Http_Fsockopen::test() )
    6965                                $working_transport = new WP_Http_Fsockopen();
    7066                }
    7167
     
    8177         * to send content, but the streams transport can. This is a limitation that
    8278         * is addressed here.
    8379         *
    84          * @since {@internal Version Unknown}}
     80         * @since 2.7
    8581         * @access private
    8682         *
    8783         * @return object|null Null if no transports are available, HTTP transport object.
    8884         */
    89         function &_postTransport()
    90         {
     85        function &_postTransport() {
    9186                static $working_transport;
    9287
    93                 if( is_null($working_transport) ) {
    94                         if( true === WP_Http_Streams::test() )
     88                if ( is_null($working_transport) ) {
     89                        if ( true === WP_Http_Streams::test() )
    9590                                $working_transport = new WP_Http_Streams();
    96                         else if( true === WP_Http_ExtHttp::test() )
     91                        else if ( true === WP_Http_ExtHttp::test() )
    9792                                $working_transport = new WP_Http_ExtHttp();
    98                         else if( true === WP_Http_Fsockopen::test() )
     93                        else if ( true === WP_Http_Fsockopen::test() )
    9994                                $working_transport = new WP_Http_Fsockopen();
    10095                }
    10196
     
    106101         * Retrieve the location and set the class properties after the site has been retrieved.
    107102         *
    108103         * @access public
    109          * @since {@internal Version Unknown}}
     104         * @since 2.7
    110105         *
    111106         * @param string $url
    112107         * @param string|array $headers Optional. Either the header string or array of Header name and value pairs. Expects sanitized.
     
    114109         * @param str|array $type Optional. Should be an already processed array with HTTP arguments.
    115110         * @return boolean
    116111         */
    117         function request($url, $args=array(), $headers=null, $body=null)
    118         {
     112        function request($url, $args = array(), $headers = null, $body = null) {
    119113                global $wp_version;
    120114
    121115                $defaults = array(
     
    126120
    127121                $r = wp_parse_args( $args, $defaults );
    128122
    129                 if( !is_null($headers) && !is_array($headers) ) {
     123                if ( ! is_null($headers) && ! is_array($headers) ) {
    130124                        $processedHeaders = WP_Http::processHeaders($headers);
    131125                        $headers = $processedHeaders['headers'];
    132126                } else {
    133127                        $headers = array();
    134128                }
    135129
    136                 if( !isset($headers['user-agent']) || !isset($headers['User-Agent']) )
    137                         $headers['user-agent'] = apply_filters('http_headers_useragent', 'WordPress/'.$wp_version );
     130                if ( ! isset($headers['user-agent']) || ! isset($headers['User-Agent']) )
     131                        $headers['user-agent'] = apply_filters('http_headers_useragent', 'WordPress/' . $wp_version );
    138132
    139                 if( is_null($body) )
     133                if ( is_null($body) )
    140134                        $transport = WP_Http::_getTransport();
    141135                else
    142136                        $transport = WP_Http::_postTransport();
     
    150144         * Used for sending data that is expected to be in the body.
    151145         *
    152146         * @access public
    153          * @since {@internal Version Unknown}}
     147         * @since 2.7
    154148         *
    155149         * @param string $url The location of the site and page to retrieve.
    156150         * @param string|array $headers Optional. Either the header string or array of Header name and value pairs.
    157151         * @param string $body Optional. The body that should be sent. Expected to be already processed.
    158152         * @return boolean
    159153         */
    160         function post($url, $args=array(), $headers=null, $body=null)
    161         {
     154        function post($url, $args = array(), $headers = null, $body = null) {
    162155                $defaults = array('method' => 'POST');
    163156                $r = wp_parse_args( $args, $defaults );
    164157                return $this->request($url, $headers, $body, $r);
     
    170163         * Used for sending data that is expected to be in the body.
    171164         *
    172165         * @access public
    173          * @since {@internal Version Unknown}}
     166         * @since 2.7
    174167         *
    175168         * @param string|array $headers Optional. Either the header string or array of Header name and value pairs.
    176169         * @param string $body Optional. The body that should be sent. Expected to be already processed.
    177170         * @return boolean
    178171         */
    179         function get($url, $args=array(), $headers=null, $body=null)
    180         {
     172        function get($url, $args = array(), $headers = null, $body = null) {
    181173                $defaults = array('method' => 'GET');
    182174                $r = wp_parse_args( $args, $defaults );
    183175                return $this->request($url, $headers, $body, $r);
     
    189181         * Used for sending data that is expected to be in the body.
    190182         *
    191183         * @access public
    192          * @since {@internal Version Unknown}}
     184         * @since 2.7
    193185         *
    194186         * @param string|array $headers Optional. Either the header string or array of Header name and value pairs.
    195187         * @param string $body Optional. The body that should be sent. Expected to be already processed.
    196188         * @return boolean
    197189         */
    198         function head($url, $args=array(), $headers=null, $body=null)
    199         {
     190        function head($url, $args = array(), $headers = null, $body = null) {
    200191                $defaults = array('method' => 'HEAD');
    201192                $r = wp_parse_args( $args, $defaults );
    202193                return $this->request($url, $r, $headers, $body);
     
    207198         *
    208199         * @access public
    209200         * @static
    210          * @since {@internal Version Unknown}}
     201         * @since 2.7
    211202         *
    212203         * @param string $strResponse The full response string
    213204         * @return array Array with 'headers' and 'body' keys.
    214205         */
    215         function processResponse($strResponse)
    216         {
     206        function processResponse($strResponse) {
    217207                list($theHeaders, $theBody) = explode("\r\n\r\n", $strResponse, 2);
    218208                return array('headers' => $theHeaders, 'body' => $theBody);
    219209        }
     
    223213         *
    224214         * @access public
    225215         * @static
    226          * @since {@internal Version Unknown}}
     216         * @since 2.7
    227217         *
    228218         * @param array $response Array with code and message keys
    229219         * @return bool True if 40x Response, false if something else.
    230220         */
    231         function is400Response($response)
    232         {
    233                 if( (int) substr($response, 0, 1) == 4 )
     221        function is400Response($response) {
     222                if ( (int) substr($response, 0, 1) == 4 )
    234223                        return true;
    235224                return false;
    236225        }
     
    240229         *
    241230         * @access public
    242231         * @static
    243          * @since {@internal Version Unknown}}
     232         * @since 2.7
    244233         *
    245234         * @param array $headers Array with headers
    246235         * @return bool True if Location header is found.
    247236         */
    248         function isRedirect($headers)
    249         {
    250                 if( isset($headers['location']) )
     237        function isRedirect($headers) {
     238                if ( isset($headers['location']) )
    251239                        return true;
    252240                return false;
    253241        }
     
    259247         *
    260248         * @access public
    261249         * @static
    262          * @since {@internal Version Unknown}}
     250         * @since 2.7
    263251         *
    264252         * @param string|array $headers
    265253         * @return array
    266254         */
    267         function processHeaders($headers)
    268         {
    269                 if( is_array($headers) )
     255        function processHeaders($headers) {
     256                if ( is_array($headers) )
    270257                        return $headers;
    271258
    272259                $headers = explode("\n", str_replace(array("\r"), '', $headers) );
     
    274261                $response = array('code' => 0, 'message' => '');
    275262
    276263                $newheaders = array();
    277                 foreach($headers as $tempheader) {
    278                         if( empty($tempheader) )
     264                foreach ( $headers as $tempheader ) {
     265                        if ( empty($tempheader) )
    279266                                continue;
    280267
    281                         if( false === strpos($tempheader, ':') ) {
    282                                 list( , $iResponseCode, $strResponseMsg) = explode(" ", $tempheader, 3);
     268                        if ( false === strpos($tempheader, ':') ) {
     269                                list( , $iResponseCode, $strResponseMsg) = explode(' ', $tempheader, 3);
    283270                                $response['code'] = $iResponseCode;
    284271                                $response['message'] = $strResponseMsg;
    285272                                continue;
    286273                        }
    287274
    288                         list($key, $value) = explode(":", $tempheader, 2);
     275                        list($key, $value) = explode(':', $tempheader, 2);
    289276
    290                         if( !empty($value) )
     277                        if ( ! empty($value) )
    291278                                $newheaders[strtolower($key)] = trim($value);
    292279                }
    293280
     
    302289 *
    303290 * @package WordPress
    304291 * @subpackage HTTP
    305  * @since {@internal Version Unknown}}
     292 * @since 2.7
    306293 */
    307 class WP_Http_Fsockopen
    308 {
     294class WP_Http_Fsockopen {
    309295        /**
    310296         * Retrieve the location and set the class properties after the site has been retrieved.
    311297         *
    312          * @since {@internal Version Unknown}}
     298         * @since 2.7
    313299         * @access public
    314300         * @param string $url
    315301         * @param string|array $headers Optional. Either the header string or array of Header name and value pairs. Expects sanitized.
     
    317303         * @param str|array $type Optional. Should be an already processed array with HTTP arguments.
    318304         * @return boolean
    319305         */
    320         function request($url, $args=array(), $headers=null, $body=null)
    321         {
     306        function request($url, $args = array(), $headers = null, $body = null) {
    322307                $defaults = array(
    323308                        'method' => 'GET', 'timeout' => 3,
    324309                        'redirection' => 5, 'httpversion' => '1.0'
     
    333318
    334319                $secure_transport = false;
    335320
    336                 if( !isset($arrURL['port']) ) {
    337                         if( (($arrURL['scheme'] == 'ssl' || $arrURL['scheme'] == 'https')) && extension_loaded('openssl') ) {
    338                                 $arrURL['host'] = 'ssl://'.$arrURL['host'];
     321                if ( ! isset($arrURL['port']) ) {
     322                        if ( ($arrURL['scheme'] == 'ssl' || $arrURL['scheme'] == 'https') && extension_loaded('openssl') ) {
     323                                $arrURL['host'] = 'ssl://' . $arrURL['host'];
    339324                                $arrURL['port'] = apply_filters('http_request_default_port', 443);
    340325                                $secure_transport = true;
    341                         }
    342                         else
     326                        } else {
    343327                                $arrURL['port'] = apply_filters('http_request_default_port', 80);
    344                 }
    345                 else
     328                        }
     329                } else {
    346330                        $arrURL['port'] = apply_filters('http_request_port', $arrURL['port']);
     331                }
    347332
    348                 if( true === $secure_transport )
     333                if ( true === $secure_transport )
    349334                        $error_reporting = error_reporting(0);
    350335
    351336                $handle = fsockopen($arrURL['host'], $arrURL['port'], $iError, $strError, apply_filters('http_request_timeout', absint($r['timeout']) ) );
    352337
    353                 if( false === $handle ) {
    354                         return new WP_Error('http_request_failed', $iError.': '.$strError);
    355                 }
     338                if ( false === $handle )
     339                        return new WP_Error('http_request_failed', $iError . ': ' . $strError);
    356340
    357341                $requestPath = $arrURL['path'] . ( isset($arrURL['query']) ? '?' . $arrURL['query'] : '' );
    358                 $requestPath = (empty($requestPath)) ? '/' : $requestPath;
     342                $requestPath = empty($requestPath) ? '/' : $requestPath;
    359343
    360344                $strHeaders = '';
    361                 $strHeaders .= strtoupper($r['method']).' '.$requestPath.' HTTP/'.$r['httpversion']."\r\n";
    362                 $strHeaders .= 'Host: '.$arrURL['host']."\r\n";
     345                $strHeaders .= strtoupper($r['method']) . ' ' . $requestPath . ' HTTP/' . $r['httpversion'] . "\r\n";
     346                $strHeaders .= 'Host: ' . $arrURL['host'] . "\r\n";
    363347
    364                 if( is_array($header) ) {
    365                         foreach( (array) $this->getHeaders() as $header => $headerValue)
    366                                 $strHeaders .= $header.': '.$headerValue."\r\n";
    367                 } else
     348                if ( is_array($header) ) {
     349                        foreach ( (array) $this->getHeaders() as $header => $headerValue )
     350                                $strHeaders .= $header . ': ' . $headerValue . "\r\n";
     351                } else {
    368352                        $strHeaders .= $header;
     353                }
    369354
    370355                $strHeaders .= "\r\n";
    371356
    372                 if( !is_null($body) )
     357                if ( ! is_null($body) )
    373358                        $strHeaders .= $body;
    374359
    375360                fwrite($handle, $strHeaders);
    376361
    377362                $strResponse = '';
    378                 while( !feof($handle) ) {
     363                while ( ! feof($handle) )
    379364                        $strResponse .= fread($handle, 4096);
    380                 }
     365
    381366                fclose($handle);
    382367
    383                 if( true === $secure_transport )
     368                if ( true === $secure_transport )
    384369                        error_reporting($error_reporting);
    385370
    386371                $process = WP_Http::processResponse($strResponse);
    387372                $arrHeaders = WP_Http::processHeaders($process['headers']);
    388373
    389                 if( WP_Http::is400Response($arrHeaders['response']) )
    390                         return new WP_Error('http_request_failed', $arrHeaders['response']['code'] .': '. $arrHeaders['response']['message']);
     374                if ( WP_Http::is400Response($arrHeaders['response']) )
     375                        return new WP_Error('http_request_failed', $arrHeaders['response']['code'] . ': ' . $arrHeaders['response']['message']);
    391376
    392                 if( isset($arrHeaders['headers']['location']) ) {
    393                         if( $r['redirection']-- > 0 ) {
     377                if ( isset($arrHeaders['headers']['location']) ) {
     378                        if ( $r['redirection']-- > 0 )
    394379                                return $this->request($arrHeaders['headers']['location'], $r, $headers, $body);
    395                         } else
     380                        else
    396381                                return new WP_Error('http_request_failed', __('Too many redirects.'));
    397382                }
    398383
     
    402387        /**
    403388         * Whether this class can be used for retrieving an URL.
    404389         *
    405          * @since {@internal Version Unknown}}
     390         * @since 2.7
    406391         * @static
    407392         * @return boolean False means this class can not be used, true means it can.
    408393         */
    409         function test()
    410         {
    411                 if( function_exists( 'fsockopen' ) )
     394        function test() {
     395                if ( function_exists( 'fsockopen' ) )
    412396                        return true;
    413397
    414398                return false;
     
    426410 *
    427411 * @package WordPress
    428412 * @subpackage HTTP
    429  * @since {@internal Version Unknown}}
     413 * @since 2.7
    430414 */
    431 class WP_Http_Fopen
    432 {
     415class WP_Http_Fopen {
    433416        /**
    434417         * Retrieve the location and set the class properties after the site has been retrieved.
    435418         *
    436419         * @access public
    437          * @since {@internal Version Unknown}}
     420         * @since 2.7
    438421         *
    439422         * @param string $url
    440423         * @param string|array $headers Optional. Either the header string or array of Header name and value pairs. Expects sanitized.
     
    442425         * @param str|array $type Optional. Should be an already processed array with HTTP arguments.
    443426         * @return boolean
    444427         */
    445         function request($url, $args=array(), $headers=null, $body=null)
    446         {
     428        function request($url, $args = array(), $headers = null, $body = null) {
    447429                global $http_response_header;
    448430
    449431                $defaults = array(
     
    455437
    456438                $arrURL = parse_url($url);
    457439
    458                 if( 'http' != $arrURL['scheme'] || 'https' != $arrURL['scheme'] )
     440                if ( 'http' != $arrURL['scheme'] || 'https' != $arrURL['scheme'] )
    459441                        $url = str_replace($arrURL['scheme'], 'http', $url);
    460442
    461443                $handle = fopen($url, 'rb');
    462444
    463                 if(!$handle)
    464                         return new WP_Error('http_request_failed', sprintf(__("Could not open handle for fopen() to %s"), $url));
     445                if (! $handle)
     446                        return new WP_Error('http_request_failed', sprintf(__('Could not open handle for fopen() to %s'), $url));
    465447
    466                 if( function_exists('stream_set_timeout') )
     448                if ( function_exists('stream_set_timeout') )
    467449                        stream_set_timeout($handle, apply_filters('http_request_timeout', $r['timeout']) );
    468450
    469451                $strResponse = '';
    470                 while(!feof($handle)) {
     452                while ( ! feof($handle) )
    471453                        $strResponse .= fread($handle, 4096);
    472                 }
    473454
    474455                $theHeaders = '';
    475                 if( function_exists('stream_get_meta_data') ) {
     456                if ( function_exists('stream_get_meta_data') ) {
    476457                        $meta = stream_get_meta_data($handle);
    477458                        $theHeaders = $meta['wrapper_data'];
    478459                } else {
     
    490471         * @static
    491472         * @return boolean False means this class can not be used, true means it can.
    492473         */
    493         function test()
    494         {
    495                 if( !function_exists('fopen') || (function_exists('ini_get') && true != ini_get('allow_url_fopen')) )
     474        function test() {
     475                if ( ! function_exists('fopen') || (function_exists('ini_get') && true != ini_get('allow_url_fopen')) )
    496476                        return false;
    497477
    498478                return true;
     
    509489 *
    510490 * @package WordPress
    511491 * @subpackage HTTP
    512  * @since {@internal Version Unknown}}
     492 * @since 2.7
    513493 */
    514 class WP_Http_Streams
    515 {
     494class WP_Http_Streams {
    516495        /**
    517496         * Retrieve the location and set the class properties after the site has been retrieved.
    518497         *
    519498         * @access public
    520          * @since {@internal Version Unknown}}
     499         * @since 2.7
    521500         *
    522501         * @param string $url
    523502         * @param str|array $args Optional. Override the defaults.
     
    525504         * @param string $body Optional. The body that should be sent. Expected to be already processed.
    526505         * @return boolean
    527506         */
    528         function request($url, $args=array(), $headers=null, $body=null)
    529         {
     507        function request($url, $args = array(), $headers = null, $body = null) {
    530508                $defaults = array(
    531509                        'method' => 'GET', 'timeout' => 3,
    532510                        'redirection' => 5, 'httpversion' => '1.0'
     
    536514
    537515                $arrURL = parse_url($url);
    538516
    539                 if( 'http' != $arrURL['scheme'] || 'https' != $arrURL['scheme'] )
     517                if ( 'http' != $arrURL['scheme'] || 'https' != $arrURL['scheme'] )
    540518                        $url = str_replace($arrURL['scheme'], 'http', $url);
    541519
    542520                $arrContext = array('http' =>
     
    549527                        )
    550528                );
    551529
    552                 if( !is_null($body) )
     530                if ( ! is_null($body) )
    553531                        $arrContext['http']['content'] = $body;
    554532
    555533                $context = stream_context_create($arrContext);
     
    558536
    559537                stream_set_timeout($handle, apply_filters('http_request_stream_timeout', $this->timeout) );
    560538
    561                 if(!$handle)
    562                         return new WP_Error('http_request_failed', sprintf(__("Could not open handle for fopen() to %s"), $url));
     539                if (! $handle)
     540                        return new WP_Error('http_request_failed', sprintf(__('Could not open handle for fopen() to %s'), $url));
    563541
    564542                $strResponse = stream_get_contents($handle);
    565543                $meta = stream_get_meta_data($handle);
     
    575553         *
    576554         * @static
    577555         * @access public
    578          * @since {@internal Version Unknown}}
     556         * @since 2.7
    579557         *
    580558         * @return boolean False means this class can not be used, true means it can.
    581559         */
    582         function test()
    583         {
    584                 if( !function_exists('fopen') || (function_exists('ini_get') && true != ini_get('allow_url_fopen')) )
     560        function test() {
     561                if ( ! function_exists('fopen') || (function_exists('ini_get') && true != ini_get('allow_url_fopen')) )
    585562                        return false;
    586563
    587                 if( version_compare(PHP_VERSION, '5.0', '<') )
     564                if ( version_compare(PHP_VERSION, '5.0', '<') )
    588565                        return false;
    589566
    590567                return true;
     
    600577 *
    601578 * @package WordPress
    602579 * @subpackage HTTP
    603  * @since {@internal Version Unknown}}
     580 * @since 2.7
    604581 */
    605 class WP_Http_ExtHTTP
    606 {
     582class WP_Http_ExtHTTP {
    607583        /**
    608584         * Retrieve the location and set the class properties after the site has been retrieved.
    609585         *
    610586         * @access public
    611          * @since {@internal Version Unknown}}
     587         * @since 2.7
    612588         *
    613589         * @param string $url
    614590         * @param str|array $args Optional. Override the defaults.
     
    616592         * @param string $body Optional. The body that should be sent. Expected to be already processed.
    617593         * @return boolean
    618594         */
    619         function request($url, $args=array(), $headers=null, $body=null)
    620         {
     595        function request($url, $args = array(), $headers = null, $body = null) {
    621596                global $wp_version;
    622597
    623598                $defaults = array(
    624599                        'method' => 'GET', 'timeout' => 3,
    625600                        'redirection' => 5, 'httpversion' => '1.0',
    626                         'user_agent' => apply_filters('http_headers_useragent', 'WordPress/'.$wp_version)
     601                        'user_agent' => apply_filters('http_headers_useragent', 'WordPress/' . $wp_version)
    627602                );
    628603
    629604                $r = wp_parse_args( $args, $defaults );
    630605
    631                 if( isset($headers['User-Agent']) )
     606                if ( isset($headers['User-Agent']) )
    632607                        unset($headers['User-Agent']);
    633608
    634                 switch($r['method'])
    635                 {
     609                switch ( $r['method'] ) {
    636610                        case 'GET':
    637611                                $r['method'] = HTTP_METH_GET;
    638612                                break;
     
    648622
    649623                $arrURL = parse_url($url);
    650624
    651                 if( 'http' != $arrURL['scheme'] || 'https' != $arrURL['scheme'] )
     625                if ( 'http' != $arrURL['scheme'] || 'https' != $arrURL['scheme'] )
    652626                        $url = str_replace($arrURL['scheme'], 'http', $url);
    653627
    654628                $options = array(
     
    661635
    662636                $strResponse = http_request($r['method'], $url, $body, $options, $info);
    663637
    664                 if( false === $strResponse )
    665                         return new WP_Error('http_request_failed', $info['response_code'] .': '. $info['error']);
     638                if ( false === $strResponse )
     639                        return new WP_Error('http_request_failed', $info['response_code'] . ': ' . $info['error']);
    666640
    667641                list($theHeaders, $theBody) = explode("\r\n\r\n", $strResponse, 2);
    668642                $theHeaders = WP_Http::processHeaders($theHeaders);
     
    678652         * Whether this class can be used for retrieving an URL.
    679653         *
    680654         * @static
    681          * @since {@internal Version Unknown}}
     655         * @since 2.7
    682656         *
    683657         * @return boolean False means this class can not be used, true means it can.
    684658         */
    685         function test()
    686         {
    687                 if( function_exists('http_request') )
     659        function test() {
     660                if ( function_exists('http_request') )
    688661                        return true;
    689662
    690663                return false;
     
    694667/**
    695668 * Returns the initialized WP_Http Object
    696669 *
    697  * @since {@internal Version Unknown}}
     670 * @since 2.7
    698671 * @access private
    699672 *
    700673 * @return WP_Http HTTP Transport object.
     
    702675function &_wp_http_get_object() {
    703676        static $http;
    704677
    705         if( is_null($http) )
     678        if ( is_null($http) )
    706679                $http = new WP_Http();
    707680
    708681        return $http;
     
    733706 * This function is called first to make the request and there are other API
    734707 * functions to abstract out the above convoluted setup.
    735708 *
    736  * @since {@internal Version Unknown}}
     709 * @since 2.7
    737710 *
    738711 * @param string $url Site URL to retrieve.
    739712 * @param array $args Optional. Override the defaults.
     
    741714 * @param string $body Optional. The body that should be sent. Expected to be already processed.
    742715 * @return string The body of the response
    743716 */
    744 function wp_remote_request($url, $args=array(), $headers=null, $body=null) {
     717function wp_remote_request($url, $args = array(), $headers = null, $body = null) {
    745718        $objFetchSite = _wp_http_get_object();
    746719
    747720        return $objFetchSite->request($url, $headers, $body, $args);
     
    752725 *
    753726 * @see wp_remote_request() For more information on the response array format.
    754727 *
    755  * @since {@internal Version Unknown}}
     728 * @since 2.7
    756729 *
    757730 * @param string $url Site URL to retrieve.
    758731 * @param array $args Optional. Override the defaults.
     
    760733 * @param string $body Optional. The body that should be sent. Expected to be already processed.
    761734 * @return string The body of the response
    762735 */
    763 function wp_remote_get($url, $args=array(), $headers=null, $body=null) {
     736function wp_remote_get($url, $args = array(), $headers = null, $body = null) {
    764737        $objFetchSite = _wp_http_get_object();
    765738
    766739        return $objFetchSite->get($url, $headers, $body, $args);
     
    771744 *
    772745 * @see wp_remote_request() For more information on the response array format.
    773746 *
    774  * @since {@internal Version Unknown}}
     747 * @since 2.7
    775748 *
    776749 * @param string $url Site URL to retrieve.
    777750 * @param array $args Optional. Override the defaults.
     
    779752 * @param string $body Optional. The body that should be sent. Expected to be already processed.
    780753 * @return string The body of the response
    781754 */
    782 function wp_remote_post($url, $args=array(), $headers=null, $body=null) {
     755function wp_remote_post($url, $args = array(), $headers = null, $body = null) {
    783756        $objFetchSite = _wp_http_get_object();
    784757
    785758        return $objFetchSite->post($url, $headers, $body, $args);
     
    790763 *
    791764 * @see wp_remote_request() For more information on the response array format.
    792765 *
    793  * @since {@internal Version Unknown}}
     766 * @since 2.7
    794767 *
    795768 * @param string $url Site URL to retrieve.
    796769 * @param array $args Optional. Override the defaults.
     
    798771 * @param string $body Optional. The body that should be sent. Expected to be already processed.
    799772 * @return string The body of the response
    800773 */
    801 function wp_remote_head($url, $args=array(), $headers=null, $body=null) {
     774function wp_remote_head($url, $args = array(), $headers = null, $body = null) {
    802775        $objFetchSite = _wp_http_get_object();
    803776
    804777        return $objFetchSite->head($url, $headers, $body, $args);
     
    807780/**
    808781 * Retrieve only the headers from the raw response.
    809782 *
    810  * @since {@internal Version Unknown}}
     783 * @since 2.7
    811784 *
    812785 * @param array $response HTTP response.
    813786 * @return array The headers of the response. Empty array if incorrect parameter given.
    814787 */
    815788function wp_remote_retrieve_headers(&$response) {
    816         if( !isset($response['headers']) || !is_array($response['headers']))
     789        if ( ! isset($response['headers']) || ! is_array($response['headers']))
    817790                return array();
    818791
    819792        return $response['headers'];
     
    822795/**
    823796 * Retrieve a single header by name from the raw response.
    824797 *
    825  * @since {@internal Version Unknown}}
     798 * @since 2.7
    826799 *
    827800 * @param array $response
    828801 * @param string $header Header name to retrieve value from.
    829802 * @return array The header value. Empty string on if incorrect parameter given.
    830803 */
    831804function wp_remote_retrieve_header(&$response, $header) {
    832         if( !isset($response['headers']) || !is_array($response['headers']))
     805        if ( ! isset($response['headers']) || ! is_array($response['headers']))
    833806                return '';
    834807
    835         if( array_key_exists($header, $response['headers']) )
     808        if ( array_key_exists($header, $response['headers']) )
    836809                return $response['headers'][$header];
    837810
    838811        return '';
     
    843816 *
    844817 * Will return an empty array if incorrect parameter value is given.
    845818 *
    846  * @since {@internal Version Unknown}}
     819 * @since 2.7
    847820 *
    848821 * @param array $response HTTP response.
    849822 * @return array The keys 'code' and 'message' give information on the response.
    850823 */
    851824function wp_remote_retrieve_response_code(&$response) {
    852         if( !isset($response['response']) || !is_array($response['response']))
     825        if ( ! isset($response['response']) || ! is_array($response['response']))
    853826                return '';
    854827
    855828        return $response['response']['code'];
     
    860833 *
    861834 * Will return an empty array if incorrect parameter value is given.
    862835 *
    863  * @since {@internal Version Unknown}}
     836 * @since 2.7
    864837 *
    865838 * @param array $response HTTP response.
    866839 * @return array The keys 'code' and 'message' give information on the response.
    867840 */
    868841function wp_remote_retrieve_response_message(&$response) {
    869         if( !isset($response['response']) || !is_array($response['response']))
     842        if ( ! isset($response['response']) || ! is_array($response['response']))
    870843                return '';
    871844
    872845        return $response['response']['message'];
     
    875848/**
    876849 * Retrieve only the body from the raw response.
    877850 *
    878  * @since {@internal Version Unknown}}
     851 * @since 2.7
    879852 *
    880853 * @param array $response HTTP response.
    881854 * @return string The body of the response. Empty string if no body or incorrect parameter given.
    882855 */
    883856function wp_remote_retrieve_body(&$response) {
    884         if( !isset($response['body']) )
     857        if ( ! isset($response['body']) )
    885858                return '';
    886859
    887860        return $response['body'];