Index: wp-includes/http.php
===================================================================
--- wp-includes/http.php	(revision 11829)
+++ wp-includes/http.php	(working copy)
@@ -599,6 +599,8 @@
 		);
 
 		$r = wp_parse_args( $args, $defaults );
+		if ( ! isset($r['max-redirects']) )
+			$r['max-redirects'] = $r['redirection'];
 
 		if ( isset($r['headers']['User-Agent']) ) {
 			$r['user-agent'] = $r['headers']['User-Agent'];
@@ -726,7 +728,7 @@
 			return new WP_Error('http_request_failed', $arrHeaders['response']['code'] . ': ' . $arrHeaders['response']['message']);
 
 		// If location is found, then assume redirect and redirect to location.
-		if ( isset($arrHeaders['headers']['location']) ) {
+		if ( isset($arrHeaders['headers']['location']) && 0 != $r['max-redirects'] ) {
 			if ( $r['redirection']-- > 0 ) {
 				return $this->request($arrHeaders['headers']['location'], $r);
 			} else {
@@ -1303,7 +1305,7 @@
 			curl_setopt( $handle, CURLOPT_HEADER, false );
 
 		// The option doesn't work with safe mode or when open_basedir is set.
-		if ( !ini_get('safe_mode') && !ini_get('open_basedir') )
+		if ( 0 != $r['redirection'] && !ini_get('safe_mode') && !ini_get('open_basedir') )
 			curl_setopt( $handle, CURLOPT_FOLLOWLOCATION, true );
 
 		if ( !empty( $r['headers'] ) ) {
@@ -1334,8 +1336,6 @@
 		$theResponse = curl_exec( $handle );
 
 		if ( !empty($theResponse) ) {
-			$parts = explode("\r\n\r\n", $theResponse);
-
 			$headerLength = curl_getinfo($handle, CURLINFO_HEADER_SIZE);
 			$theHeaders = trim( substr($theResponse, 0, $headerLength) );
 			$theBody = substr( $theResponse, $headerLength );
@@ -1345,10 +1345,10 @@
 			}
 			$theHeaders = WP_Http::processHeaders($theHeaders);
 		} else {
+			if ( in_array( curl_getinfo( $handle, CURLINFO_HTTP_CODE ), array(301, 302) ) )
+				return new WP_Error('http_request_failed', __('Too many redirects.'));
 			if ( $curl_error = curl_error($handle) )
 				return new WP_Error('http_request_failed', $curl_error);
-			if ( in_array( curl_getinfo( $handle, CURLINFO_HTTP_CODE ), array(301, 302) ) )
-				return new WP_Error('http_request_failed', __('Too many redirects.'));
 
 			$theHeaders = array( 'headers' => array(), 'cookies' => array() );
 			$theBody = '';
