Index: wp-includes/http.php
===================================================================
--- wp-includes/http.php	(revision 8518)
+++ wp-includes/http.php	(working copy)
@@ -115,7 +115,7 @@
 		$defaults = array(
 			'method' => 'GET', 'timeout' => 3,
 			'redirection' => 5, 'redirected' => false,
-			'httpversion' => '1.0'
+			'httpversion' => '1.0', 'blocking' => true
 		);
 
 		$r = wp_parse_args( $args, $defaults );
@@ -261,7 +261,7 @@
 		$response = array('code' => 0, 'message' => '');
 
 		$newheaders = array();
-		foreach($headers as $tempheader) {
+		foreach ( $headers as $tempheader ) {
 			if ( empty($tempheader) )
 				continue;
 
@@ -306,7 +306,8 @@
 	function request($url, $args = array(), $headers = null, $body = null) {
 		$defaults = array(
 			'method' => 'GET', 'timeout' => 3,
-			'redirection' => 5, 'httpversion' => '1.0'
+			'redirection' => 5, 'httpversion' => '1.0',
+			'blocking' => true
 		);
 
 		$r = wp_parse_args( $args, $defaults );
@@ -323,34 +324,34 @@
 				$arrURL['host'] = 'ssl://' . $arrURL['host'];
 				$arrURL['port'] = apply_filters('http_request_default_port', 443);
 				$secure_transport = true;
+			} else {
+				$arrURL['port'] = apply_filters('http_request_default_port', 80);
 			}
-			else
-				$arrURL['port'] = apply_filters('http_request_default_port', 80);
+		} else {
+			$arrURL['port'] = apply_filters('http_request_port', $arrURL['port']);
 		}
-		else
-			$arrURL['port'] = apply_filters('http_request_port', $arrURL['port']);
 
 		if ( true === $secure_transport )
 			$error_reporting = error_reporting(0);
 
 		$handle = fsockopen($arrURL['host'], $arrURL['port'], $iError, $strError, apply_filters('http_request_timeout', absint($r['timeout']) ) );
 
-		if ( false === $handle ) {
+		if ( false === $handle )
 			return new WP_Error('http_request_failed', $iError . ': ' . $strError);
-		}
 
 		$requestPath = $arrURL['path'] . ( isset($arrURL['query']) ? '?' . $arrURL['query'] : '' );
-		$requestPath = (empty($requestPath)) ? '/' : $requestPath;
+		$requestPath = empty($requestPath) ? '/' : $requestPath;
 
 		$strHeaders = '';
 		$strHeaders .= strtoupper($r['method']) . ' ' . $requestPath . ' HTTP/' . $r['httpversion'] . "\r\n";
 		$strHeaders .= 'Host: ' . $arrURL['host'] . "\r\n";
 
 		if ( is_array($header) ) {
-			foreach( (array) $this->getHeaders() as $header => $headerValue)
+			foreach ( (array) $this->getHeaders() as $header => $headerValue )
 				$strHeaders .= $header . ': ' . $headerValue . "\r\n";
-		} else
+		} else {
 			$strHeaders .= $header;
+		}
 
 		$strHeaders .= "\r\n";
 
@@ -359,6 +360,9 @@
 
 		fwrite($handle, $strHeaders);
 
+		if ( ! $r['blocking']) )
+			return array( 'headers' => array(), 'body' => '', 'response' => array() );
+
 		$strResponse = '';
 		while ( ! feof($handle) )
 			$strResponse .= fread($handle, 4096);
@@ -430,7 +434,8 @@
 
 		$defaults = array(
 			'method' => 'GET', 'timeout' => 3,
-			'redirection' => 5, 'httpversion' => '1.0'
+			'redirection' => 5, 'httpversion' => '1.0',
+			'blocking' => true
 		);
 
 		$r = wp_parse_args( $args, $defaults );
@@ -448,6 +453,9 @@
 		if ( function_exists('stream_set_timeout') )
 			stream_set_timeout($handle, apply_filters('http_request_timeout', $r['timeout']) );
 
+		if ( ! $r['blocking']) )
+			return array( 'headers' => array(), 'body' => '', 'response' => array() );
+
 		$strResponse = '';
 		while ( ! feof($handle) )
 			$strResponse .= fread($handle, 4096);
@@ -507,7 +515,8 @@
 	function request($url, $args = array(), $headers = null, $body = null) {
 		$defaults = array(
 			'method' => 'GET', 'timeout' => 3,
-			'redirection' => 5, 'httpversion' => '1.0'
+			'redirection' => 5, 'httpversion' => '1.0',
+			'blocking' => true
 		);
 
 		$r = wp_parse_args( $args, $defaults );
@@ -536,9 +545,12 @@
 
 		stream_set_timeout($handle, apply_filters('http_request_stream_timeout', $this->timeout) );
 
-		if (! $handle)
+		if ( ! $handle)
 			return new WP_Error('http_request_failed', sprintf(__('Could not open handle for fopen() to %s'), $url));
 
+		if ( ! $r['blocking']) )
+			return array( 'headers' => array(), 'body' => '', 'response' => array() );
+
 		$strResponse = stream_get_contents($handle);
 		$meta = stream_get_meta_data($handle);
 
@@ -574,6 +586,7 @@
  * Requires the HTTP extension to be installed.
  *
  * Last ditch effort to retrieve the URL before complete failure.
+ * Does not support non-blocking requests.
  *
  * @package WordPress
  * @subpackage HTTP
@@ -598,7 +611,7 @@
 		$defaults = array(
 			'method' => 'GET', 'timeout' => 3,
 			'redirection' => 5, 'httpversion' => '1.0',
-			'user_agent' => apply_filters('http_headers_useragent', 'WordPress/' . $wp_version)
+			'blocking' => true, 'user_agent' => apply_filters('http_headers_useragent', 'WordPress/' . $wp_version)
 		);
 
 		$r = wp_parse_args( $args, $defaults );
@@ -860,4 +873,4 @@
 	return $response['body'];
 }
 
-?>
\ No newline at end of file
+?>

