Make WordPress Core


Ignore:
Timestamp:
12/11/2010 05:51:49 AM (16 years ago)
Author:
dd32
Message:

Coding Standards clean-up, Variable typo fix ($errstr), Svn property correction. See #10588

File:
1 edited

Legend:

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

    • Property svn:eol-style set to native
    r16438 r16871  
    77 *
    88 */
    9 class WP_HTTP_IXR_Client extends IXR_Client
    10 {
    11     function WP_HTTP_IXR_Client($server, $path = false, $port = 80, $timeout = 15)
    12     {
    13         if (!$path) {
    14             // Assume we have been given a URL instead
    15             $bits = parse_url($server);
    16             $this->scheme = $bits['scheme'];
    17             $this->server = $bits['host'];
    18             $this->port = isset($bits['port']) ? $bits['port'] : 80;
    19             $this->path = isset($bits['path']) ? $bits['path'] : '/';
     9class WP_HTTP_IXR_Client extends IXR_Client {
     10        function WP_HTTP_IXR_Client($server, $path = false, $port = 80, $timeout = 15) {
     11                if ( ! $path ) {
     12                        // Assume we have been given a URL instead
     13                        $bits = parse_url($server);
     14                        $this->scheme = $bits['scheme'];
     15                        $this->server = $bits['host'];
     16                        $this->port = isset($bits['port']) ? $bits['port'] : 80;
     17                        $this->path = !empty($bits['path']) ? $bits['path'] : '/';
    2018
    21             // Make absolutely sure we have a path
    22             if (!$this->path) {
    23                 $this->path = '/';
    24             }
    25         } else {
    26                 $this->scheme = 'http';
    27             $this->server = $server;
    28             $this->path = $path;
    29             $this->port = $port;
    30         }
    31         $this->useragent = 'The Incutio XML-RPC PHP Library';
    32         $this->timeout = $timeout;
    33     }
     19                        // Make absolutely sure we have a path
     20                        if ( ! $this->path )
     21                                $this->path = '/';
     22                } else {
     23                        $this->scheme = 'http';
     24                        $this->server = $server;
     25                        $this->path = $path;
     26                        $this->port = $port;
     27                }
     28                $this->useragent = 'The Incutio XML-RPC PHP Library';
     29                $this->timeout = $timeout;
     30        }
    3431
    35     function query()
    36     {
    37         $args = func_get_args();
    38         $method = array_shift($args);
    39         $request = new IXR_Request($method, $args);
    40         $xml = $request->getXml();
     32        function query() {
     33                $args = func_get_args();
     34                $method = array_shift($args);
     35                $request = new IXR_Request($method, $args);
     36                $xml = $request->getXml();
    4137
    42         $url = $this->scheme . '://' . $this->server . ':' . $this->port . $this->path;
    43         $args = array(
    44             'headers'    => array('Content-Type' => 'text/xml'),
    45             'user-agent' => $this->useragent,
    46             'body'       => $xml,
    47         );
     38                $url = $this->scheme . '://' . $this->server . ':' . $this->port . $this->path;
     39                $args = array(
     40                        'headers'    => array('Content-Type' => 'text/xml'),
     41                        'user-agent' => $this->useragent,
     42                        'body'       => $xml,
     43                );
    4844
    49         // Merge Custom headers ala #8145
     45                // Merge Custom headers ala #8145
    5046                foreach ( $this->headers as $header => $value )
    5147                        $args['headers'][$header] = $value;
    … …  
    5450                        $args['timeout'] = $this->timeout;
    5551
    56         // Now send the request
    57         if ($this->debug) {
    58             echo '<pre class="ixr_request">'.htmlspecialchars($xml)."\n</pre>\n\n";
    59         }
     52                // Now send the request
     53                if ( $this->debug )
     54                        echo '<pre class="ixr_request">' . htmlspecialchars($xml) . "\n</pre>\n\n";
    6055
    6156                $response = wp_remote_post($url, $args);
    … …  
    6459                        $errno    = $response->get_error_code();
    6560                        $errorstr = $response->get_error_message();
    66                         $this->error = new IXR_Error(-32300, "transport error: $errno $errstr");
     61                        $this->error = new IXR_Error(-32300, "transport error: $errno $errorstr");
    6762                        return false;
    6863                }
    6964
    70                 $code = $response['response']['code'];
    71                 if ( $code != 200 ) {
    72                         $this->error = new IXR_Error(-32301, "transport error - HTTP status code was not 200 ($code)");             return false;
    73         }
     65                if ( $response['response']['code'] != 200 ) {
     66                        $this->error = new IXR_Error(-32301, "transport error - HTTP status code was not 200 ({$response['response']['code']})");
     67                        return false;
     68                }
    7469
    75         if ($this->debug) {
    76             echo '<pre class="ixr_response">'.htmlspecialchars($response['body'])."\n</pre>\n\n";
    77         }
     70                if ( $this->debug )
     71                        echo '<pre class="ixr_response">' . htmlspecialchars($response['body']) . "\n</pre>\n\n";
    7872
    79         // Now parse what we've got back
    80         $this->message = new IXR_Message( $response['body'] );
    81         if (!$this->message->parse()) {
    82             // XML error
    83             $this->error = new IXR_Error(-32700, 'parse error. not well formed');
    84             return false;
    85         }
     73                // Now parse what we've got back
     74                $this->message = new IXR_Message( $response['body'] );
     75                if ( ! $this->message->parse() ) {
     76                        // XML error
     77                        $this->error = new IXR_Error(-32700, 'parse error. not well formed');
     78                        return false;
     79                }
    8680
    87         // Is the message a fault?
    88         if ($this->message->messageType == 'fault') {
    89             $this->error = new IXR_Error($this->message->faultCode, $this->message->faultString);
    90             return false;
    91         }
     81                // Is the message a fault?
     82                if ( $this->message->messageType == 'fault' ) {
     83                        $this->error = new IXR_Error($this->message->faultCode, $this->message->faultString);
     84                        return false;
     85                }
    9286
    93         // Message must be OK
    94         return true;
    95     }
     87                // Message must be OK
     88                return true;
     89        }
    9690}
    9791?>
Note: See TracChangeset for help on using the changeset viewer.