X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/fef8173b8c3bad08f495551e43cfdeac1cae6021..caeaf8dc94b5e3f75dc98ec92dc7b76049cdddb6:/wp-includes/class-wp-http-ixr-client.php diff --git a/wp-includes/class-wp-http-ixr-client.php b/wp-includes/class-wp-http-ixr-client.php index 4c36334e..0605955d 100644 --- a/wp-includes/class-wp-http-ixr-client.php +++ b/wp-includes/class-wp-http-ixr-client.php @@ -7,18 +7,35 @@ * */ class WP_HTTP_IXR_Client extends IXR_Client { - function WP_HTTP_IXR_Client($server, $path = false, $port = 80, $timeout = 15) { + public $scheme; + /** + * @var IXR_Error + */ + public $error; + + /** + * @param string $server + * @param string|bool $path + * @param int|bool $port + * @param int $timeout + */ + public function __construct($server, $path = false, $port = false, $timeout = 15) { if ( ! $path ) { // Assume we have been given a URL instead $bits = parse_url($server); $this->scheme = $bits['scheme']; $this->server = $bits['host']; - $this->port = isset($bits['port']) ? $bits['port'] : 80; + $this->port = isset($bits['port']) ? $bits['port'] : $port; $this->path = !empty($bits['path']) ? $bits['path'] : '/'; // Make absolutely sure we have a path - if ( ! $this->path ) + if ( ! $this->path ) { $this->path = '/'; + } + + if ( ! empty( $bits['query'] ) ) { + $this->path .= '?' . $bits['query']; + } } else { $this->scheme = 'http'; $this->server = $server; @@ -29,13 +46,14 @@ class WP_HTTP_IXR_Client extends IXR_Client { $this->timeout = $timeout; } - function query() { + public function query() { $args = func_get_args(); $method = array_shift($args); $request = new IXR_Request($method, $args); $xml = $request->getXml(); - $url = $this->scheme . '://' . $this->server . ':' . $this->port . $this->path; + $port = $this->port ? ":$this->port" : ''; + $url = $this->scheme . '://' . $this->server . $port . $this->path; $args = array( 'headers' => array('Content-Type' => 'text/xml'), 'user-agent' => $this->useragent, @@ -62,16 +80,16 @@ class WP_HTTP_IXR_Client extends IXR_Client { return false; } - if ( $response['response']['code'] != 200 ) { - $this->error = new IXR_Error(-32301, "transport error - HTTP status code was not 200 ({$response['response']['code']})"); + if ( 200 != wp_remote_retrieve_response_code( $response ) ) { + $this->error = new IXR_Error(-32301, 'transport error - HTTP status code was not 200 (' . wp_remote_retrieve_response_code( $response ) . ')'); return false; } if ( $this->debug ) - echo '
' . htmlspecialchars($response['body']) . "\n
\n\n"; + echo '
' . htmlspecialchars( wp_remote_retrieve_body( $response ) ) . "\n
\n\n"; // Now parse what we've got back - $this->message = new IXR_Message( $response['body'] ); + $this->message = new IXR_Message( wp_remote_retrieve_body( $response ) ); if ( ! $this->message->parse() ) { // XML error $this->error = new IXR_Error(-32700, 'parse error. not well formed'); @@ -88,4 +106,3 @@ class WP_HTTP_IXR_Client extends IXR_Client { return true; } } -?> \ No newline at end of file