Index: wp-includes/class-IXR.php
===================================================================
--- wp-includes/class-IXR.php	(revision 11808)
+++ wp-includes/class-IXR.php	(working copy)
@@ -507,6 +507,7 @@
         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->path = isset($bits['path']) ? $bits['path'] : '/';
@@ -515,6 +516,7 @@
                 $this->path = '/';
             }
         } else {
+            $this->scheme = 'http';
             $this->server = $server;
             $this->path = $path;
             $this->port = $port;
@@ -526,65 +528,45 @@
         $args = func_get_args();
         $method = array_shift($args);
         $request = new IXR_Request($method, $args);
-        $length = $request->getLength();
         $xml = $request->getXml();
-        $r = "\r\n";
-        $request  = "POST {$this->path} HTTP/1.0$r";
 
-		$this->headers['Host']			= $this->server;
-		$this->headers['Content-Type']	= 'text/xml';
-		$this->headers['User-Agent']	= $this->useragent;
-		$this->headers['Content-Length']= $length;
+        $url = $this->scheme . '://' . $this->server . ':' . $this->port . $this->path; 
+        $args = array(
+            'headers'    => array('Content-Type' => 'text/xml'),
+            'user-agent' => $this->useragent,
+            'body'       => $xml,
+        );
 
-		foreach( $this->headers as $header => $value ) {
-			$request .= "{$header}: {$value}{$r}";
-		}
-		$request .= $r;
+        foreach ( $this->headers as $header => $value )
+            $args['headers'][$header] = $value;
 
-        $request .= $xml;
+        if ( $this->timeout !== false )
+            $args['timeout'] = $this->timeout;
+
         // Now send the request
         if ($this->debug) {
-            echo '<pre class="ixr_request">'.htmlspecialchars($request)."\n</pre>\n\n";
+            echo '<pre class="ixr_request">'.htmlspecialchars($xml)."\n</pre>\n\n";
         }
-        if ($this->timeout) {
-            $fp = @fsockopen($this->server, $this->port, $errno, $errstr, $this->timeout);
-        } else {
-            $fp = @fsockopen($this->server, $this->port, $errno, $errstr);
+
+        $response = wp_remote_post($url, $args);
+
+        if ( is_wp_error($response) ) {
+            $errno    = $response->get_error_code();
+            $errorstr = $response->get_error_message();
+            $this->error = new IXR_Error(-32300, "transport error: $errno $errstr");
+            return false;
         }
-        if (!$fp) {
-            $this->error = new IXR_Error(-32300, "transport error - could not open socket: $errno $errstr");
+
+        $code = $response['response']['code'];
+        if ( $code != 200 ) {
+            $this->error = new IXR_Error(-32301, "transport error - HTTP status code was not 200 ($code)");
             return false;
         }
-        fputs($fp, $request);
-        $contents = '';
-        $debug_contents = '';
-        $gotFirstLine = false;
-        $gettingHeaders = true;
-        while (!feof($fp)) {
-            $line = fgets($fp, 4096);
-            if (!$gotFirstLine) {
-                // Check line for '200'
-                if (strstr($line, '200') === false) {
-                    $this->error = new IXR_Error(-32301, 'transport error - HTTP status code was not 200');
-                    return false;
-                }
-                $gotFirstLine = true;
-            }
-            if (trim($line) == '') {
-                $gettingHeaders = false;
-            }
-            if (!$gettingHeaders) {
-                $contents .= trim($line);
-            }
-            if ($this->debug) {
-                $debug_contents .= $line;
-            }
-        }
         if ($this->debug) {
+            $debug_contents = $response['body'];
             echo '<pre class="ixr_response">'.htmlspecialchars($debug_contents)."\n</pre>\n\n";
         }
-        // Now parse what we've got back
-        $this->message = new IXR_Message($contents);
+        $this->message = new IXR_Message($response['body']);
         if (!$this->message->parse()) {
             // XML error
             $this->error = new IXR_Error(-32700, 'parse error. not well formed');
