Index: wp-includes/pluggable.php
===================================================================
--- wp-includes/pluggable.php	(revision 7986)
+++ wp-includes/pluggable.php	(working copy)
@@ -1445,4 +1445,161 @@
 }
 endif;
 
+if( ! function_exists('remote_http') ){
+/**
+ * remote_http() - performs an HTTP/1.0 request.
+ *
+ * Makes a remote HTTP request and returns a object represnting the request.
+ *
+ * Things to note about this function:
+ * * This function does not support Proxies
+ * * This function is not cached
+ * * $data may either be an array of values to be sent, Or it may be a string of raw data. 
+ * * The headers sent by this function can be modified/added to by the 'remote_http_headers' filter.
+ * * All headers returned by this function are normalised to lowercase names.
+ * * Be default, This function will follow 5 redirections, The final return object will have a property 'redirectionpath' which contains the object representing each redirection attempt.
+ * * Defaults can be overridden via the 2nd argument $args, See code for values to be overridden.
+ * 
+ * Example Use:
+ *
+ *  $request = remote_http('http://my-site/api/', 'method=post&timeout=30', array('PostField' => 'PostDataValue'), array('User-Agent' => 'My Super Plugin'));
+ * HTTP Request:
+ *  
+ *  POST /api/ HTTP/1.0
+ *  Host: my-site
+ *  User-Agent: My Super Plugin
+ *  Content-Length: 23
+ *  Content-Type: application/x-www-form-urlencoded; charset=UTF-8
+ *  
+ *  PostField=PostDataValue
+ *  
+ * Return Object:
+ *  object(stdClass)[69]
+ *    public 'status' => string '200' (length=3)
+ *    public 'statusvalue' => string 'OK' (length=2)
+ *    public 'headers' => 
+ *       array
+ *        'date' => string 'Sun, 25 May 2008 06:36:40 GMT' (length=29)
+ *        'server' => string 'Apache' (length=6)
+ *        'connection' => string 'close' (length=5)
+ *        'content-type' => string 'text/html' (length=9)
+ *    public 'content' => string 'Return Value from API Service here' (length=34)
+ *
+ * Example use with a String as the $data param:
+ * 
+ * $request = remote_http('http://my-site/api/', array('method' => 'post'), serialize( array(time()) ));
+ * HTTP Request:
+ *  POST /api/ HTTP/1.0
+ *  Host: my-site
+ *  User-Agent: WordPress/2.6; http://your-site/
+ *  Content-Length: 23
+ *  Content-Type: application/x-www-form-urlencoded; charset=UTF-8
+ * 
+ *  a:1:{i:0;i:1211698656;}
+ *
+ * @since 2.6
+ *
+ * @param string $url the URL to open
+ * @param string|array $args 
+ * @param string|array $data (optional) an Associative array containing data keys to be sent, or a pre-made HTTP query string
+ * @param array $headers (optional) Extra headers to send with the connection. eg. array('Referer' => 'http://localhost/');
+ * @return bool|object Returns false on failure, Else an object with 4 properties: "status", "statusname", "headers" and "content", If a redirection has taken place, an extra 5th property "redirectionpath" will contain objects of the other HTTP Requests which were made.
+ */
+function remote_http($url, $args = array(), $data='', $headers = array()){
+	global $wp_version;
+	
+	$defaults = array(
+		'method' => 'GET', 'timeout' => 3,
+		'allowed_methods' => array('GET', 'POST', 'HEAD'),
+		'redirection' => 5, 'redirected' => false,
+		'httpversion' => '1.0'
+	);
+
+	$r = wp_parse_args( $args, $defaults );
+	extract( $r );//Allow it to overwrite $data/$headers if user has specified them in this array, However, this is an unsupported use of the function.
+
+	if( ! function_exists('fsockopen') )
+		return false;
+
+	if( is_array($data) )
+		$data = http_build_query($data);
+
+	$headers = wp_parse_args($headers);
+
+	$method = strtoupper($method);
+	if( ! in_array($method, $allowed_methods) )
+		$method = 'GET';
+
+	$port = 80;
+	$schema = 'http';
+	$path = $host = $query = '';
+	$parts = parse_url($url);
+	extract($parts);
+
+	if( ! empty($query) )
+		$query = "?$query";
+	
+	$http_request  = "$method $path$query HTTP/$httpversion\r\n";
+	$http_request .= "Host: $host\r\n";
+
+	if( ! isset($headers['User-Agent']) )
+		$headers['User-Agent'] = 'WordPress/' . $wp_version . '; ' . get_bloginfo('url');
+
+	if( ! empty($data) ) {
+		$headers['Content-Length'] = strlen($data);
+		
+		if( ! isset($headers['Content-Type']) )
+			$headers['Content-Type'] = 'application/x-www-form-urlencoded; charset=' . get_option('blog_charset');
+	}
+
+	$headers = apply_filters('remote_http_headers', $headers);
+	
+	if( ! empty($headers) )
+		foreach($headers as $header => $value)
+			$http_request .= "$header: $value\r\n";
+
+	$http_request .= "\r\n";
+	if( ! empty($data) )
+		$http_request .= $data;
+
+	$response = '';
+	if( false == ( $fs = @fsockopen( $host, $port, $errno, $errstr, $timeout) ) || ! is_resource($fs) )
+		return false;
+
+	fwrite($fs, $http_request);
+
+	while ( !feof($fs) )
+		$response .= fgets($fs, 1160); // One TCP-IP packet
+	fclose($fs);
+	$response = explode("\r\n\r\n", $response, 2);
+	
+	$ret = (object)array('status' => 0, 'statusvalue' => '', 'headers' => array(), 'content'=> $response[1]);
+
+	foreach( explode("\n", $response[0]) as $rheader) {
+		if( strpos($rheader, ':') ) { //Proper header
+			list($header, $value) = explode(':', $rheader, 2);
+			if( !empty($header) && ! empty($value) )
+				$ret->headers[ strtolower(trim($header)) ] = trim($value);
+		} else if( strpos($rheader, 'HTTP') > -1) { //A Status header.
+			list(,$status, $status_value) = preg_split('|\s+|', $rheader,3);
+			$ret->status = trim($status);
+			$ret->statusvalue = trim($status_value);
+		}
+	}
+
+	//Handle Redirections:
+	if ( isset($ret->headers['location']) && $redirection ) {
+		$ret->headers['x-location'] = $ret->headers['location']; //Record the location the redirection has taken us to.
+		
+		$r['redirection']--;
+		$r['redirected'] = true;
+
+		$redirected = remote_http($ret->headers['location'], $r, $data, $headers);
+		$redirected->redirectionpath[] = $ret;
+		$ret = $redirected;
+	}
+
+	return $ret;
+}
+}
 ?>
