Make WordPress Core

Changeset 15285


Ignore:
Timestamp:
06/19/2010 07:02:09 AM (16 years ago)
Author:
dd32
Message:

Some coding standards cleanups for WP_HTTP. Props hakre for initial patch. See #13897

File:
1 edited

Legend:

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

    r15284 r15285  
    239239                        return $pre;
    240240
    241                 $arrURL = parse_url($url);
     241                $arrURL = parse_url( $url );
    242242
    243243                if ( empty( $url ) || empty( $arrURL['scheme'] ) )
    … …  
    245245
    246246                if ( $this->block_request( $url ) )
    247                         return new WP_Error('http_request_failed', __('User has blocked requests through HTTP.'));
     247                        return new WP_Error( 'http_request_failed', __( 'User has blocked requests through HTTP.' ) );
    248248
    249249                // Determine if this is a https call and pass that on to the transport functions
    … …  
    252252
    253253                // Determine if this request is to OUR install of WordPress
    254                 $homeURL = parse_url( get_bloginfo('url') );
     254                $homeURL = parse_url( get_bloginfo( 'url' ) );
    255255                $r['local'] = $homeURL['host'] == $arrURL['host'] || 'localhost' == $arrURL['host'];
    256                 unset($homeURL);
     256                unset( $homeURL );
    257257
    258258                if ( is_null( $r['headers'] ) )
    259259                        $r['headers'] = array();
    260260
    261                 if ( ! is_array($r['headers']) ) {
    262                         $processedHeaders = WP_Http::processHeaders($r['headers']);
     261                if ( ! is_array( $r['headers'] ) ) {
     262                        $processedHeaders = WP_Http::processHeaders( $r['headers'] );
    263263                        $r['headers'] = $processedHeaders['headers'];
    264264                }
    265265
    266                 if ( isset($r['headers']['User-Agent']) ) {
     266                if ( isset( $r['headers']['User-Agent'] ) ) {
    267267                        $r['user-agent'] = $r['headers']['User-Agent'];
    268                         unset($r['headers']['User-Agent']);
    269                 }
    270 
    271                 if ( isset($r['headers']['user-agent']) ) {
     268                        unset( $r['headers']['User-Agent'] );
     269                }
     270
     271                if ( isset( $r['headers']['user-agent'] ) ) {
    272272                        $r['user-agent'] = $r['headers']['user-agent'];
    273                         unset($r['headers']['user-agent']);
     273                        unset( $r['headers']['user-agent'] );
    274274                }
    275275
    … …  
    284284                        // Also, to fix another bug, we only send when doing POST and PUT and the content-length
    285285                        // header isn't already set.
    286                         if( ($r['method'] == 'POST' || $r['method'] == 'PUT') && ! isset($r['headers']['Content-Length']) )
     286                        if ( ($r['method'] == 'POST' || $r['method'] == 'PUT') && ! isset( $r['headers']['Content-Length'] ) )
    287287                                $r['headers']['Content-Length'] = 0;
    288288
    … …  
    290290                        // this case is simply that we aren't sending any bodies and to get the transports that
    291291                        // don't support sending bodies along with those which do.
    292                         $transports = WP_Http::_getTransport($r);
     292                        $transports = WP_Http::_getTransport( $r );
    293293                } else {
    294294                        if ( is_array( $r['body'] ) || is_object( $r['body'] ) ) {
    295295                                if ( ! version_compare(phpversion(), '5.1.2', '>=') )
    296                                         $r['body'] = _http_build_query($r['body'], null, '&');
     296                                        $r['body'] = _http_build_query( $r['body'], null, '&' );
    297297                                else
    298                                         $r['body'] = http_build_query($r['body'], null, '&');
    299                                 $r['headers']['Content-Type'] = 'application/x-www-form-urlencoded; charset=' . get_option('blog_charset');
    300                                 $r['headers']['Content-Length'] = strlen($r['body']);
     298                                        $r['body'] = http_build_query( $r['body'], null, '&' );
     299                                $r['headers']['Content-Type'] = 'application/x-www-form-urlencoded; charset=' . get_option( 'blog_charset' );
     300                                $r['headers']['Content-Length'] = strlen( $r['body'] );
    301301                        }
    302302
    303303                        if ( ! isset( $r['headers']['Content-Length'] ) && ! isset( $r['headers']['content-length'] ) )
    304                                 $r['headers']['Content-Length'] = strlen($r['body']);
     304                                $r['headers']['Content-Length'] = strlen( $r['body'] );
    305305
    306306                        // The method is ambiguous, because we aren't talking about HTTP methods, the "post" in
    … …  
    308308                        // support sending the body. Not all do, depending on the limitations of the PHP core
    309309                        // limitations.
    310                         $transports = WP_Http::_postTransport($r);
     310                        $transports = WP_Http::_postTransport( $r );
    311311                }
    312312
    … …  
    315315                $response = array( 'headers' => array(), 'body' => '', 'response' => array('code' => false, 'message' => false), 'cookies' => array() );
    316316                foreach ( (array) $transports as $transport ) {
    317                         $response = $transport->request($url, $r);
    318 
    319                         do_action( 'http_api_debug', $response, 'response', get_class($transport) );
    320 
    321                         if ( ! is_wp_error($response) )
     317                        $response = $transport->request( $url, $r );
     318
     319                        do_action( 'http_api_debug', $response, 'response', get_class( $transport ) );
     320
     321                        if ( ! is_wp_error( $response ) )
    322322                                return apply_filters( 'http_response', $response, $r, $url );
    323323                }
    … …  
    622622                        $r['user-agent'] = $r['headers']['User-Agent'];
    623623                        unset($r['headers']['User-Agent']);
    624                 } else if( isset($r['headers']['user-agent']) ) {
     624                } else if ( isset($r['headers']['user-agent']) ) {
    625625                        $r['user-agent'] = $r['headers']['user-agent'];
    626626                        unset($r['headers']['user-agent']);
    … …  
    974974                        $r['user-agent'] = $r['headers']['User-Agent'];
    975975                        unset($r['headers']['User-Agent']);
    976                 } else if( isset($r['headers']['user-agent']) ) {
     976                } else if ( isset($r['headers']['user-agent']) ) {
    977977                        $r['user-agent'] = $r['headers']['user-agent'];
    978978                        unset($r['headers']['user-agent']);
    … …  
    11471147                        $r['user-agent'] = $r['headers']['User-Agent'];
    11481148                        unset($r['headers']['User-Agent']);
    1149                 } else if( isset($r['headers']['user-agent']) ) {
     1149                } else if ( isset($r['headers']['user-agent']) ) {
    11501150                        $r['user-agent'] = $r['headers']['user-agent'];
    11511151                        unset($r['headers']['user-agent']);
    … …  
    12971297                        $r['user-agent'] = $r['headers']['User-Agent'];
    12981298                        unset($r['headers']['User-Agent']);
    1299                 } else if( isset($r['headers']['user-agent']) ) {
     1299                } else if ( isset($r['headers']['user-agent']) ) {
    13001300                        $r['user-agent'] = $r['headers']['user-agent'];
    13011301                        unset($r['headers']['user-agent']);
Note: See TracChangeset for help on using the changeset viewer.