*
*/
class WP_HTTP_IXR_Client extends IXR_Client {
+ public $scheme;
+ /**
+ * @var IXR_Error
+ */
+ public $error;
- function __construct($server, $path = false, $port = false, $timeout = 15) {
+ /**
+ * @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);
if ( ! $this->path ) {
$this->path = '/';
}
-
+
if ( ! empty( $bits['query'] ) ) {
$this->path .= '?' . $bits['query'];
}
$this->timeout = $timeout;
}
- function query() {
+ /**
+ * @return bool
+ */
+ public function query() {
$args = func_get_args();
$method = array_shift($args);
$request = new IXR_Request($method, $args);
);
// Merge Custom headers ala #8145
- foreach ( $this->headers as $header => $value )
+ foreach ( $this->headers as $header => $value ) {
$args['headers'][$header] = $value;
+ }
+
+ /**
+ * Filters the headers collection to be sent to the XML-RPC server.
+ *
+ * @since 4.4.0
+ *
+ * @param array $headers Array of headers to be sent.
+ */
+ $args['headers'] = apply_filters( 'wp_http_ixr_client_headers', $args['headers'] );
- if ( $this->timeout !== false )
+ if ( $this->timeout !== false ) {
$args['timeout'] = $this->timeout;
+ }
// Now send the request
- if ( $this->debug )
+ if ( $this->debug ) {
echo '<pre class="ixr_request">' . htmlspecialchars($xml) . "\n</pre>\n\n";
+ }
$response = wp_remote_post($url, $args);
return false;
}
- if ( $this->debug )
+ if ( $this->debug ) {
echo '<pre class="ixr_response">' . htmlspecialchars( wp_remote_retrieve_body( $response ) ) . "\n</pre>\n\n";
+ }
// Now parse what we've got back
$this->message = new IXR_Message( wp_remote_retrieve_body( $response ) );