Changeset 42343 for trunk/src/wp-includes/class-wp-http-ixr-client.php
- Timestamp:
- 11/30/2017 11:09:33 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-http-ixr-client.php
r37492 r42343 5 5 * @package WordPress 6 6 * @since 3.1.0 7 *8 7 */ 9 8 class WP_HTTP_IXR_Client extends IXR_Client { … … 20 19 * @param int $timeout 21 20 */ 22 public function __construct( $server, $path = false, $port = false, $timeout = 15) {21 public function __construct( $server, $path = false, $port = false, $timeout = 15 ) { 23 22 if ( ! $path ) { 24 23 // Assume we have been given a URL instead 25 $bits = parse_url($server);24 $bits = parse_url( $server ); 26 25 $this->scheme = $bits['scheme']; 27 26 $this->server = $bits['host']; 28 $this->port = isset($bits['port']) ? $bits['port'] : $port;29 $this->path = !empty($bits['path']) ? $bits['path'] : '/';27 $this->port = isset( $bits['port'] ) ? $bits['port'] : $port; 28 $this->path = ! empty( $bits['path'] ) ? $bits['path'] : '/'; 30 29 31 30 // Make absolutely sure we have a path … … 40 39 $this->scheme = 'http'; 41 40 $this->server = $server; 42 $this->path = $path;43 $this->port = $port;41 $this->path = $path; 42 $this->port = $port; 44 43 } 45 44 $this->useragent = 'The Incutio XML-RPC PHP Library'; 46 $this->timeout = $timeout;45 $this->timeout = $timeout; 47 46 } 48 47 … … 51 50 */ 52 51 public function query() { 53 $args = func_get_args();54 $method = array_shift($args);55 $request = new IXR_Request( $method, $args);56 $xml = $request->getXml();52 $args = func_get_args(); 53 $method = array_shift( $args ); 54 $request = new IXR_Request( $method, $args ); 55 $xml = $request->getXml(); 57 56 58 57 $port = $this->port ? ":$this->port" : ''; 59 $url = $this->scheme . '://' . $this->server . $port . $this->path;58 $url = $this->scheme . '://' . $this->server . $port . $this->path; 60 59 $args = array( 61 'headers' => array( 'Content-Type' => 'text/xml'),60 'headers' => array( 'Content-Type' => 'text/xml' ), 62 61 'user-agent' => $this->useragent, 63 62 'body' => $xml, … … 66 65 // Merge Custom headers ala #8145 67 66 foreach ( $this->headers as $header => $value ) { 68 $args['headers'][ $header] = $value;67 $args['headers'][ $header ] = $value; 69 68 } 70 69 … … 84 83 // Now send the request 85 84 if ( $this->debug ) { 86 echo '<pre class="ixr_request">' . htmlspecialchars( $xml) . "\n</pre>\n\n";85 echo '<pre class="ixr_request">' . htmlspecialchars( $xml ) . "\n</pre>\n\n"; 87 86 } 88 87 89 $response = wp_remote_post( $url, $args);88 $response = wp_remote_post( $url, $args ); 90 89 91 if ( is_wp_error( $response) ) {92 $errno = $response->get_error_code();93 $errorstr = $response->get_error_message();94 $this->error = new IXR_Error( -32300, "transport error: $errno $errorstr");90 if ( is_wp_error( $response ) ) { 91 $errno = $response->get_error_code(); 92 $errorstr = $response->get_error_message(); 93 $this->error = new IXR_Error( -32300, "transport error: $errno $errorstr" ); 95 94 return false; 96 95 } 97 96 98 97 if ( 200 != wp_remote_retrieve_response_code( $response ) ) { 99 $this->error = new IXR_Error( -32301, 'transport error - HTTP status code was not 200 (' . wp_remote_retrieve_response_code( $response ) . ')');98 $this->error = new IXR_Error( -32301, 'transport error - HTTP status code was not 200 (' . wp_remote_retrieve_response_code( $response ) . ')' ); 100 99 return false; 101 100 } … … 109 108 if ( ! $this->message->parse() ) { 110 109 // XML error 111 $this->error = new IXR_Error( -32700, 'parse error. not well formed');110 $this->error = new IXR_Error( -32700, 'parse error. not well formed' ); 112 111 return false; 113 112 } … … 115 114 // Is the message a fault? 116 115 if ( $this->message->messageType == 'fault' ) { 117 $this->error = new IXR_Error( $this->message->faultCode, $this->message->faultString);116 $this->error = new IXR_Error( $this->message->faultCode, $this->message->faultString ); 118 117 return false; 119 118 }
Note: See TracChangeset
for help on using the changeset viewer.