Index: wp-includes/http.php
===================================================================
--- wp-includes/http.php	(revision 10696)
+++ wp-includes/http.php	(working copy)
@@ -98,16 +98,16 @@
 			if ( true === WP_Http_ExtHttp::test($args) ) {
 				$working_transport['exthttp'] = new WP_Http_ExtHttp();
 				$blocking_transport[] = &$working_transport['exthttp'];
-			} else if ( true === WP_Http_Curl::test($args) ) {
+			} elseif ( true === WP_Http_Curl::test($args) ) {
 				$working_transport['curl'] = new WP_Http_Curl();
 				$blocking_transport[] = &$working_transport['curl'];
-			} else if ( true === WP_Http_Streams::test($args) ) {
+			} elseif ( true === WP_Http_Streams::test($args) ) {
 				$working_transport['streams'] = new WP_Http_Streams();
 				$blocking_transport[] = &$working_transport['streams'];
-			} else if ( true === WP_Http_Fopen::test($args) ) {
+			} elseif ( true === WP_Http_Fopen::test($args) ) {
 				$working_transport['fopen'] = new WP_Http_Fopen();
 				$blocking_transport[] = &$working_transport['fopen'];
-			} else if ( true === WP_Http_Fsockopen::test($args) ) {
+			} elseif ( true === WP_Http_Fsockopen::test($args) ) {
 				$working_transport['fsockopen'] = new WP_Http_Fsockopen();
 				$blocking_transport[] = &$working_transport['fsockopen'];
 			}
@@ -118,7 +118,7 @@
 			}
 		}
 
-		if( has_filter('http_transport_get_debug') )
+		if ( has_filter('http_transport_get_debug') )
 			do_action('http_transport_get_debug', $working_transport, $blocking_transport, $nonblocking_transport);
 
 		if ( isset($args['blocking']) && !$args['blocking'] )
@@ -149,13 +149,13 @@
 			if ( true === WP_Http_ExtHttp::test($args) ) {
 				$working_transport['exthttp'] = new WP_Http_ExtHttp();
 				$blocking_transport[] = &$working_transport['exthttp'];
-			} else if ( true === WP_Http_Curl::test($args) ) {
+			} elseif ( true === WP_Http_Curl::test($args) ) {
 				$working_transport['curl'] = new WP_Http_Curl();
 				$blocking_transport[] = &$working_transport['curl'];
-			} else if ( true === WP_Http_Streams::test($args) ) {
+			} elseif ( true === WP_Http_Streams::test($args) ) {
 				$working_transport['streams'] = new WP_Http_Streams();
 				$blocking_transport[] = &$working_transport['streams'];
-			} else if ( true === WP_Http_Fsockopen::test($args) ) {
+			} elseif ( true === WP_Http_Fsockopen::test($args) ) {
 				$working_transport['fsockopen'] = new WP_Http_Fsockopen();
 				$blocking_transport[] = &$working_transport['fsockopen'];
 			}
@@ -166,7 +166,7 @@
 			}
 		}
 
-		if( has_filter('http_transport_post_debug') )
+		if ( has_filter('http_transport_post_debug') )
 			do_action('http_transport_post_debug', $working_transport, $blocking_transport, $nonblocking_transport);
 
 		if ( isset($args['blocking']) && !$args['blocking'] )
@@ -243,16 +243,12 @@
 
 		// Determine if this is a https call and pass that on to the transport functions
 		// so that we can blacklist the transports that do not support ssl verification
-		if ( $arrURL['scheme'] == 'https' || $arrURL['scheme'] == 'ssl' )
-			$r['ssl'] = true;
-		else
-			$r['ssl'] = false;
+		$r['ssl'] = $arrURL['scheme'] == 'https' || $arrURL['scheme'] == 'ssl';
 
-                // Determine if this request is to OUR install of WordPress
-                if ( stristr(get_bloginfo('url'), $arrURL['host']) )
-                        $r['local'] = true;
-                else
-                        $r['local'] = false;
+		// Determine if this request is to OUR install of WordPress
+		$homeURL = parse_url(get_bloginfo('url'));
+		$r['local'] = $homeURL['host'] == $arrURL['host'] || 'localhost' == $arrURL['host'];
+		unset($homeURL);
 
 		if ( is_null( $r['headers'] ) )
 			$r['headers'] = array();
@@ -275,7 +271,7 @@
 		// Construct Cookie: header if any cookies are set
 		WP_Http::buildCookieHeader( $r );
 
-		if( WP_Http_Encoding::is_available() )
+		if ( WP_Http_Encoding::is_available() )
 			$r['headers']['Accept-Encoding'] = WP_Http_Encoding::accept_encoding();
 
 		if ( is_null($r['body']) ) {
@@ -296,17 +292,17 @@
 			$transports = WP_Http::_postTransport($r);
 		}
 
-		if( has_action('http_api_debug') )
+		if ( has_action('http_api_debug') )
 			do_action('http_api_debug', $transports, 'transports_list');
 
 		$response = array( 'headers' => array(), 'body' => '', 'response' => array('code' => false, 'message' => false), 'cookies' => array() );
-		foreach( (array) $transports as $transport ) {
+		foreach ( (array) $transports as $transport ) {
 			$response = $transport->request($url, $r);
 			
-			if( has_action('http_api_debug') )
+			if ( has_action('http_api_debug') )
 				do_action( 'http_api_debug', $response, 'response', get_class($transport) );
 
-			if( ! is_wp_error($response) )
+			if ( ! is_wp_error($response) )
 				return $response;
 		}
 
@@ -419,11 +415,12 @@
 
 			if ( !empty( $value ) ) {
 				$key = strtolower( $key );
-				if ( isset( $newheaders[$key] ) ) {
+
+				if ( isset( $newheaders[$key] ) )
 					$newheaders[$key] = array( $newheaders[$key], trim( $value ) );
-				} else {
+				else
 					$newheaders[$key] = trim( $value );
-				}
+
 				if ( 'set-cookie' == strtolower( $key ) )
 					$cookies[] = new WP_Http_Cookie( $value );
 			}
@@ -448,9 +445,8 @@
 	function buildCookieHeader( &$r ) {
 		if ( ! empty($r['cookies']) ) {
 			$cookies_header = '';
-			foreach ( (array) $r['cookies'] as $cookie ) {
+			foreach ( (array) $r['cookies'] as $cookie )
 				$cookies_header .= $cookie->getHeaderValue() . '; ';
-			}
 			$cookies_header = substr( $cookies_header, 0, -2 );
 			$r['headers']['cookie'] = $cookies_header;
 		}
@@ -494,7 +490,7 @@
 
 				$body = ltrim(str_replace(array($match[0], $strBody), '', $body), "\n");
 
-				if( "0" == trim($body) )
+				if ( "0" == trim($body) )
 					return $parsedBody; // Ignore footer headers.
 			} else {
 				return $body;
@@ -543,9 +539,8 @@
 		if ( $uri == 'localhost' || $uri == $home['host'] )
 			return apply_filters('block_local_requests', false);
 
-		if ( defined('WP_ACCESSABLE_HOSTS') && is_array( WP_ACCESSABLE_HOSTS ) && in_array( $check['host'], WP_ACCESSABLE_HOSTS ) ) {
-				return false;
-		}
+		if ( defined('WP_ACCESSABLE_HOSTS') && is_array( WP_ACCESSABLE_HOSTS ) && in_array( $check['host'], WP_ACCESSABLE_HOSTS ) )
+			return false;
 
 		return true;
 	}
@@ -588,7 +583,7 @@
 		if ( isset($r['headers']['User-Agent']) ) {
 			$r['user-agent'] = $r['headers']['User-Agent'];
 			unset($r['headers']['User-Agent']);
-		} else if( isset($r['headers']['user-agent']) ) {
+		} elseif ( isset($r['headers']['user-agent']) ) {
 			$r['user-agent'] = $r['headers']['user-agent'];
 			unset($r['headers']['user-agent']);
 		}
@@ -606,13 +601,11 @@
 		if ( ! isset($arrURL['port']) ) {
 			if ( ($arrURL['scheme'] == 'ssl' || $arrURL['scheme'] == 'https') && extension_loaded('openssl') ) {
 				$arrURL['host'] = 'ssl://' . $arrURL['host'];
-				$arrURL['port'] = apply_filters('http_request_port', 443);
+				$arrURL['port'] = 443;
 				$secure_transport = true;
 			} else {
-				$arrURL['port'] = apply_filters('http_request_default_port', 80);
+				$arrURL['port'] = 80;
 			}
-		} else {
-			$arrURL['port'] = apply_filters('http_request_port', $arrURL['port'], $arrURL['host']);
 		}
 
 		// There are issues with the HTTPS and SSL protocols that cause errors that can be safely
@@ -625,13 +618,12 @@
 		$proxy = new WP_HTTP_Proxy();
 
 		if ( !defined('WP_DEBUG') || ( defined('WP_DEBUG') && false === WP_DEBUG ) ) {
-			if( $proxy->is_enabled() && $proxy->send_through_proxy( $url ) )
+			if ( $proxy->is_enabled() && $proxy->send_through_proxy( $url ) )
 				$handle = @fsockopen($proxy->host(), $proxy->port(), $iError, $strError, $r['timeout'] );
 			else
 				$handle = @fsockopen($arrURL['host'], $arrURL['port'], $iError, $strError, $r['timeout'] );
-		}
-		else {
-			if( $proxy->is_enabled() && $proxy->send_through_proxy( $url ) )
+		} else {
+			if ( $proxy->is_enabled() && $proxy->send_through_proxy( $url ) )
 				$handle = fsockopen($proxy->host(), $proxy->port(), $iError, $strError, $r['timeout'] );
 			else
 				$handle = fsockopen($arrURL['host'], $arrURL['port'], $iError, $strError, $r['timeout'] );
@@ -648,22 +640,24 @@
 		if ( false === $handle )
 			return new WP_Error('http_request_failed', $iError . ': ' . $strError);
 
-		// WordPress supports PHP 4.3, which has this function. Removed sanity checking for
-		// performance reasons.
 		stream_set_timeout($handle, $r['timeout'] );
 
-		$requestPath = $arrURL['path'] . ( isset($arrURL['query']) ? '?' . $arrURL['query'] : '' );
-		$requestPath = empty($requestPath) ? '/' : $requestPath;
+		if ( $proxy->is_enabled() && $proxy->send_through_proxy( $url ) ) //Some proxies require full URL in this field.
+			$requestPath = $url;
+		else
+			$requestPath = $arrURL['path'] . ( isset($arrURL['query']) ? '?' . $arrURL['query'] : '' );
 
-		$strHeaders = '';
-		$strHeaders .= strtoupper($r['method']) . ' ' . $requestPath . ' HTTP/' . $r['httpversion'] . "\r\n";
+		if ( empty($requestPath) )
+			$requestPath .= '/';
 
-		if( $proxy->is_enabled() && $proxy->send_through_proxy( $url ) )
-			$strHeaders .= 'Host: ' . $arrURL['host'] .':'. $arrURL['port'] . "\r\n";
+		$strHeaders = strtoupper($r['method']) . ' ' . $requestPath . ' HTTP/' . $r['httpversion'] . "\r\n";
+
+		if ( $proxy->is_enabled() && $proxy->send_through_proxy( $url ) )
+			$strHeaders .= 'Host: ' . $arrURL['host'] . ':' . $arrURL['port'] . "\r\n";
 		else
 			$strHeaders .= 'Host: ' . $arrURL['host'] . "\r\n";
 
-		if( isset($r['user-agent']) )
+		if ( isset($r['user-agent']) )
 			$strHeaders .= 'User-agent: ' . $r['user-agent'] . "\r\n";
 
 		if ( is_array($r['headers']) ) {
@@ -673,9 +667,8 @@
 			$strHeaders .= $r['headers'];
 		}
 
-		if ( $proxy->use_authentication() ) {
+		if ( $proxy->use_authentication() )
 			$strHeaders .= $proxy->authentication_header() . "\r\n";
-		}
 
 		$strHeaders .= "\r\n";
 
@@ -731,14 +724,20 @@
 	 * @static
 	 * @return boolean False means this class can not be used, true means it can.
 	 */
-	function test($args = array()) {
+	function test( $args = array() ) {
 		if ( false !== ($option = get_option( 'disable_fsockopen' )) && time()-$option < 43200 ) // 12 hours
 			return false;
 
-		if ( function_exists( 'fsockopen' ) && ( isset($args['ssl']) && !$args['ssl'] ) )
-			return apply_filters('use_fsockopen_transport', true);
+		$is_ssl = isset($args['ssl']) && $args['ssl'];
 
-		return false;
+		if ( ! $is_ssl && function_exists( 'fsockopen' ) )
+			$use = true;
+		elseif ( $is_ssl && extension_loaded('openssl') && function_exists( 'fsockopen' ) )
+			$use = true;
+		else
+			$use = false;
+
+		return apply_filters('use_fsockopen_transport', $use, $args);
 	}
 }
 
@@ -772,8 +771,6 @@
 	 * @return array 'headers', 'body', 'cookies' and 'response' keys.
 	 */
 	function request($url, $args = array()) {
-		global $http_response_header;
-
 		$defaults = array(
 			'method' => 'GET', 'timeout' => 5,
 			'redirection' => 5, 'httpversion' => '1.0',
@@ -799,8 +796,6 @@
 		if (! $handle)
 			return new WP_Error('http_request_failed', sprintf(__('Could not open handle for fopen() to %s'), $url));
 
-		// WordPress supports PHP 4.3, which has this function. Removed sanity
-		// checking for performance reasons.
 		stream_set_timeout($handle, $r['timeout'] );
 
 		if ( ! $r['blocking'] ) {
@@ -812,15 +807,14 @@
 		while ( ! feof($handle) )
 			$strResponse .= fread($handle, 4096);
 
-		$theHeaders = '';
 		if ( function_exists('stream_get_meta_data') ) {
 			$meta = stream_get_meta_data($handle);
 			$theHeaders = $meta['wrapper_data'];
-			if( isset( $meta['wrapper_data']['headers'] ) )
+			if ( isset( $meta['wrapper_data']['headers'] ) )
 				$theHeaders = $meta['wrapper_data']['headers'];
 		} else {
-			if( ! isset( $http_response_header ) )
-				global $http_response_header;
+			//$http_response_header is a PHP reserved variable which is set in the current-scope when using the HTTP Wrapper
+			//see http://php.oregonstate.edu/manual/en/reserved.variables.httpresponseheader.php
 			$theHeaders = $http_response_header;
 		}
 
@@ -844,19 +838,28 @@
 	 * @static
 	 * @return boolean False means this class can not be used, true means it can.
 	 */
-	function test() {
+	function test($args = array()) {
 		if ( ! function_exists('fopen') || (function_exists('ini_get') && true != ini_get('allow_url_fopen')) )
 			return false;
 
-		        if (
-                                ( isset($args['ssl']) && !$args['ssl'] ) ||
-                                ( isset($args['local']) && $args['local'] == true && apply_filters('https_local_ssl_verify', true) != true ) ||
-                                ( isset($args['local']) && $args['local'] == false && apply_filters('https_ssl_verify', true) != true ) ||
-                                ( isset($args['sslverify']) && !$args['sslverify'] )
-                        )
-				return apply_filters('use_fopen_transport', true);
+		$use = true;
 
-		return false;
+		//PHP does not verify SSL certs, We can only make a request via this transports if SSL Verification is turned off.
+		$is_ssl = isset($args['ssl']) && $args['ssl'];
+		if ( $is_ssl ) {
+			$is_local = isset($args['local']) && $args['local'];
+			$ssl_verify = isset($args['sslverify']) && $args['sslverify'];
+			if ( $is_local && true != apply_filters('https_local_ssl_verify', true) )
+				$use = true;
+			elseif ( !$is_local && true != apply_filters('https_ssl_verify', true) )
+				$use = true;
+			elseif ( !$ssl_verify )
+				$use = true;
+			else
+				$use = false;
+		}
+
+		return apply_filters('use_fopen_transport', $use, $args);
 	}
 }
 
@@ -896,7 +899,7 @@
 		if ( isset($r['headers']['User-Agent']) ) {
 			$r['user-agent'] = $r['headers']['User-Agent'];
 			unset($r['headers']['User-Agent']);
-		} else if( isset($r['headers']['user-agent']) ) {
+		} elseif ( isset($r['headers']['user-agent']) ) {
 			$r['user-agent'] = $r['headers']['user-agent'];
 			unset($r['headers']['user-agent']);
 		}
@@ -910,16 +913,23 @@
 			return new WP_Error('http_request_failed', sprintf(__('Malformed URL: %s'), $url));
 
 		if ( 'http' != $arrURL['scheme'] && 'https' != $arrURL['scheme'] )
-			$url = str_replace($arrURL['scheme'], 'http', $url);
+			$url = preg_replace('|^' . preg_quote($arrURL['scheme'], '|') . '|', 'http', $url);
 
 		// Convert Header array to string.
 		$strHeaders = '';
 		if ( is_array( $r['headers'] ) )
-			foreach( $r['headers'] as $name => $value )
+			foreach ( $r['headers'] as $name => $value )
 				$strHeaders .= "{$name}: $value\r\n";
-		else if ( is_string( $r['headers'] ) )
+		elseif ( is_string( $r['headers'] ) )
 			$strHeaders = $r['headers'];
 
+		$is_local = isset($args['local']) && $args['local'];
+		$ssl_verify = isset($args['sslverify']) && $args['sslverify'];
+		if ( $is_local )
+			$ssl_verify = apply_filters('https_local_ssl_verify', $ssl_verify);
+		elseif ( ! $is_local )
+			$ssl_verify = apply_filters('https_ssl_verify', $ssl_verify);
+
 		$arrContext = array('http' =>
 			array(
 				'method' => strtoupper($r['method']),
@@ -929,21 +939,21 @@
 				'header' => $strHeaders,
 				'timeout' => $r['timeout'],
 				'ssl' => array(
-						'verify_peer' => apply_filters('https_ssl_verify', $r['sslverify']),
-						'verify_host' => apply_filters('https_ssl_verify', $r['sslverify'])
+						'verify_peer' => $ssl_verify,
+						'verify_host' => $ssl_verify
 				)
 			)
 		);
 
 		$proxy = new WP_HTTP_Proxy();
 
-		if ( $proxy->is_enabled() && $proxy->send_through_proxy( $url ) ) { 
-			$arrContext['http']['proxy'] = 'tcp://'.$proxy->host().':'.$proxy->port();
+		if ( $proxy->is_enabled() && $proxy->send_through_proxy( $url ) ) {
+			$arrContext['http']['proxy'] = 'tcp://' . $proxy->host() . ':' . $proxy->port();
+			$arrContext['http']['request_fulluri'] = true;
 
 			// We only support Basic authentication so this will only work if that is what your proxy supports.
-			if ( $proxy->use_authentication() ) {
+			if ( $proxy->use_authentication() )
 				$arrContext['http']['header'] .= $proxy->authentication_header() . "\r\n";
-			}
 		}
 
 		if ( ! is_null($r['body']) && ! empty($r['body'] ) )
@@ -975,7 +985,7 @@
 		fclose($handle);
 
 		$processedHeaders = array();
-		if( isset( $meta['wrapper_data']['headers'] ) )
+		if ( isset( $meta['wrapper_data']['headers'] ) )
 			$processedHeaders = WP_Http::processHeaders($meta['wrapper_data']['headers']);
 		else
 			$processedHeaders = WP_Http::processHeaders($meta['wrapper_data']);
@@ -1005,7 +1015,19 @@
 		if ( version_compare(PHP_VERSION, '5.0', '<') )
 			return false;
 
-		return apply_filters('use_streams_transport', true);
+		//HTTPS via Proxy was added in 5.1.0
+		$is_ssl = isset($args['ssl']) && $args['ssl'];
+		if ( $is_ssl && version_compare(PHP_VERSION, '5.1.0', '<') ) {
+			$proxy = new WP_HTTP_Proxy();
+			/**
+			 * No URL check, as its not currently passed to the ::test() function
+			 * In the case where a Proxy is in use, Just bypass this transport for HTTPS.
+			 */
+			if ( $proxy->is_enabled() )
+				return false;
+		}
+
+		return apply_filters('use_streams_transport', true, $args);
 	}
 }
 
@@ -1046,7 +1068,7 @@
 		if ( isset($r['headers']['User-Agent']) ) {
 			$r['user-agent'] = $r['headers']['User-Agent'];
 			unset($r['headers']['User-Agent']);
-		} else if( isset($r['headers']['user-agent']) ) {
+		} elseif ( isset($r['headers']['user-agent']) ) {
 			$r['user-agent'] = $r['headers']['user-agent'];
 			unset($r['headers']['user-agent']);
 		}
@@ -1069,8 +1091,15 @@
 		$arrURL = parse_url($url);
 
 		if ( 'http' != $arrURL['scheme'] || 'https' != $arrURL['scheme'] )
-			$url = str_replace($arrURL['scheme'], 'http', $url);
+			$url = preg_replace('|^' . preg_quote($arrURL['scheme'], '|') . '|', 'http', $url);
 
+		$is_local = isset($args['local']) && $args['local'];
+		$ssl_verify = isset($args['sslverify']) && $args['sslverify'];
+		if ( $is_local )
+			$ssl_verify = apply_filters('https_local_ssl_verify', $ssl_verify);
+		elseif ( ! $is_local )
+			$ssl_verify = apply_filters('https_ssl_verify', $ssl_verify);
+
 		$options = array(
 			'timeout' => $r['timeout'],
 			'connecttimeout' => $r['timeout'],
@@ -1078,8 +1107,8 @@
 			'useragent' => $r['user-agent'],
 			'headers' => $r['headers'],
 			'ssl' => array( 
-				'verifypeer' => apply_filters('https_ssl_verify', $r['sslverify']),
-				'verifyhost' => apply_filters('https_ssl_verify', $r['sslverify'])
+				'verifypeer' => $ssl_verify,
+				'verifyhost' => $ssl_verify
 			)
 		);
 
@@ -1139,10 +1168,7 @@
 	 * @return boolean False means this class can not be used, true means it can.
 	 */
 	function test($args = array()) {
-		if ( function_exists('http_request') )
-			return apply_filters('use_http_extension_transport', true);
-
-		return false;
+		return apply_filters('use_http_extension_transport', function_exists('http_request'), $args );
 	}
 }
 
@@ -1180,7 +1206,7 @@
 		if ( isset($r['headers']['User-Agent']) ) {
 			$r['user-agent'] = $r['headers']['User-Agent'];
 			unset($r['headers']['User-Agent']);
-		} else if( isset($r['headers']['user-agent']) ) {
+		} elseif ( isset($r['headers']['user-agent']) ) {
 			$r['user-agent'] = $r['headers']['user-agent'];
 			unset($r['headers']['user-agent']);
 		}
@@ -1199,7 +1225,6 @@
 		$proxy = new WP_HTTP_Proxy();
 
 		if ( $proxy->is_enabled() && $proxy->send_through_proxy( $url ) ) {
-			curl_setopt( $handle, CURLOPT_HTTPPROXYTUNNEL, true );
 
 			$isPHP5 = version_compare(PHP_VERSION, '5.0.0', '>=');
 
@@ -1218,11 +1243,18 @@
 				curl_setopt( $handle, CURLOPT_PROXYUSERPWD, $proxy->authentication() );
 			}
 		}
+		
+		$is_local = isset($args['local']) && $args['local'];
+		$ssl_verify = isset($args['sslverify']) && $args['sslverify'];
+		if ( $is_local )
+			$ssl_verify = apply_filters('https_local_ssl_verify', $ssl_verify);
+		elseif ( ! $is_local )
+			$ssl_verify = apply_filters('https_ssl_verify', $ssl_verify);
 
 		curl_setopt( $handle, CURLOPT_URL, $url);
 		curl_setopt( $handle, CURLOPT_RETURNTRANSFER, true );
-		curl_setopt( $handle, CURLOPT_SSL_VERIFYHOST, apply_filters('https_ssl_verify', $r['sslverify']) );
-		curl_setopt( $handle, CURLOPT_SSL_VERIFYPEER, apply_filters('https_ssl_verify', $r['sslverify']) );
+		curl_setopt( $handle, CURLOPT_SSL_VERIFYHOST, $ssl_verify );
+		curl_setopt( $handle, CURLOPT_SSL_VERIFYPEER, $ssl_verify );
 		curl_setopt( $handle, CURLOPT_USERAGENT, $r['user-agent'] );
 		curl_setopt( $handle, CURLOPT_CONNECTTIMEOUT, $r['timeout'] );
 		curl_setopt( $handle, CURLOPT_TIMEOUT, $r['timeout'] );
@@ -1250,9 +1282,8 @@
 		if ( !empty( $r['headers'] ) ) {
 			// cURL expects full header strings in each element
 			$headers = array();
-			foreach ( $r['headers'] as $name => $value ) {
+			foreach ( $r['headers'] as $name => $value )
 				$headers[] = "{$name}: $value";
-			}
 			curl_setopt( $handle, CURLOPT_HTTPHEADER, $headers );
 		}
 
@@ -1317,7 +1348,7 @@
 	 */
 	function test($args = array()) {
 		if ( function_exists('curl_init') && function_exists('curl_exec') )
-			return  apply_filters('use_curl_transport', true);
+			return apply_filters('use_curl_transport', true, $args);
 
 		return false;
 	}
@@ -1353,14 +1384,6 @@
  */
 class WP_HTTP_Proxy {
 
-	function WP_HTTP_Proxy() {
-		$this->__construct();
-	}
-
-	function __construct() {
-		
-	}
-
 	/**
 	 * Whether proxy connection should be used.
 	 *
@@ -1371,7 +1394,7 @@
 	 * @return bool
 	 */
 	function is_enabled() {
-		return ( defined('WP_PROXY_HOST') && defined('WP_PROXY_PORT') );
+		return defined('WP_PROXY_HOST') && defined('WP_PROXY_PORT');
 	}
 
 	/**
@@ -1384,7 +1407,7 @@
 	 * @return bool
 	 */
 	function use_authentication() {
-		return ( defined('WP_PROXY_USERNAME') && defined('WP_PROXY_PASSWORD') );
+		return defined('WP_PROXY_USERNAME') && defined('WP_PROXY_PASSWORD');
 	}
 
 	/**
@@ -1395,7 +1418,7 @@
 	 * @return string
 	 */
 	function host() {
-		if( defined('WP_PROXY_HOST') )
+		if ( defined('WP_PROXY_HOST') )
 			return WP_PROXY_HOST;
 
 		return '';
@@ -1409,7 +1432,7 @@
 	 * @return string
 	 */
 	function port() {
-		if( defined('WP_PROXY_PORT') )
+		if ( defined('WP_PROXY_PORT') )
 			return WP_PROXY_PORT;
 
 		return '';
@@ -1423,7 +1446,7 @@
 	 * @return string
 	 */
 	function username() {
-		if( defined('WP_PROXY_USERNAME') )
+		if ( defined('WP_PROXY_USERNAME') )
 			return WP_PROXY_USERNAME;
 
 		return '';
@@ -1437,7 +1460,7 @@
 	 * @return string
 	 */
 	function password() {
-		if( defined('WP_PROXY_PASSWORD') )
+		if ( defined('WP_PROXY_PASSWORD') )
 			return WP_PROXY_PASSWORD;
 
 		return '';
@@ -1451,7 +1474,7 @@
 	 * @return string
 	 */
 	function authentication() {
-		return $this->username() .':'. $this->password();
+		return $this->username() . ':' . $this->password();
 	}
 
 	/**
@@ -1462,7 +1485,7 @@
 	 * @return string
 	 */
 	function authentication_header() {
-		return 'Proxy-Authentication: Basic '. base64_encode( $this->authentication() );
+		return 'Proxy-Authentication: Basic ' . base64_encode( $this->authentication() );
 	}
 
 	/**
@@ -1484,7 +1507,7 @@
 		$check = @parse_url($uri);
 
 		// Malformed URL, can not process, but this could mean ssl, so let through anyway.
-		if( $check === false )
+		if ( $check === false )
 			return true;
 
 		$home = parse_url( get_bloginfo('site_url') );
@@ -1492,15 +1515,12 @@
 		if ( $uri == 'localhost' || $uri == $home['host'] )
 			return false;
 
-		if ( defined('WP_PROXY_BYPASS_HOSTS') && is_array( WP_PROXY_BYPASS_HOSTS ) && in_array( $check['host'], WP_PROXY_BYPASS_HOSTS ) ) {
+		if ( defined('WP_PROXY_BYPASS_HOSTS') && is_array( WP_PROXY_BYPASS_HOSTS ) && in_array( $check['host'], WP_PROXY_BYPASS_HOSTS ) )
 			return false;
-		}
 
 		return true;
 	}
 }
-
-
 /**
  * Internal representation of a single cookie.
  *
@@ -1744,17 +1764,17 @@
 	function decompress( $compressed, $length = null ) {
 		$decompressed = gzinflate( $compressed );
 
-		if( false !== $decompressed )
+		if ( false !== $decompressed )
 			return $decompressed;
 
 		$decompressed = gzuncompress( $compressed );
 
-		if( false !== $decompressed )
+		if ( false !== $decompressed )
 			return $decompressed;
 
 		$decompressed = gzdecode( $compressed );
 
-		if( false !== $decompressed )
+		if ( false !== $decompressed )
 			return $decompressed;
 
 		return $compressed;
@@ -1769,13 +1789,13 @@
 	 */
 	function accept_encoding() {
 		$type = array();
-		if( function_exists( 'gzinflate' ) )
+		if ( function_exists( 'gzinflate' ) )
 			$type[] = 'deflate;q=1.0';
 
-		if( function_exists( 'gzuncompress' ) )
+		if ( function_exists( 'gzuncompress' ) )
 			$type[] = 'compress;q=0.5';
 
-		if( function_exists( 'gzdecode' ) )
+		if ( function_exists( 'gzdecode' ) )
 			$type[] = 'gzip;q=0.5';
 
 		return implode(', ', $type);
@@ -1801,10 +1821,10 @@
 	 * @return bool
 	 */
 	function should_decode($headers) {
-		if( is_array( $headers ) ) {
-			if( array_key_exists('content-encoding', $headers) && ! empty( $headers['content-encoding'] ) )
+		if ( is_array( $headers ) ) {
+			if ( array_key_exists('content-encoding', $headers) && ! empty( $headers['content-encoding'] ) )
 				return true;
-		} else if( is_string( $headers ) ) {
+		} elseif ( is_string( $headers ) ) {
 			return ( stripos($headers, 'content-encoding:') !== false );
 		}
 
@@ -1823,8 +1843,7 @@
 	 * @return bool
 	 */
 	function is_available() {
-		return ( function_exists('gzuncompress') || function_exists('gzdeflate') ||
-				 function_exists('gzinflate') );
+		return ( function_exists('gzuncompress') || function_exists('gzdeflate') || function_exists('gzinflate') );
 	}
 }
 
@@ -1890,7 +1909,6 @@
  */
 function wp_remote_get($url, $args = array()) {
 	$objFetchSite = _wp_http_get_object();
-
 	return $objFetchSite->get($url, $args);
 }
 
