### Eclipse Workspace Patch 1.0
#P wordpress-trunk
Index: wp-includes/class-http.php
===================================================================
--- wp-includes/class-http.php	(revision 17587)
+++ wp-includes/class-http.php	(working copy)
@@ -746,19 +746,20 @@
 	 * @return boolean False means this class can not be used, true means it can.
 	 */
 	function test( $args = array() ) {
-		if ( false !== ($option = get_option( 'disable_fsockopen' )) && time()-$option < 43200 ) // 12 hours
-			return false;
+		$is_ssl = !empty( $args['ssl'] );
 
-		$is_ssl = isset($args['ssl']) && $args['ssl'];
+		// check if fsockopen has been disabled for 12 hours
+		$use = ( $option = get_option( 'disable_fsockopen', 0 ) ) && time() - $option > 43200; // 43200 = 12 hours 
 
-		if ( ! $is_ssl && function_exists( 'fsockopen' ) )
-			$use = true;
-		elseif ( $is_ssl && extension_loaded('openssl') && function_exists( 'fsockopen' ) )
-			$use = true;
-		else
-			$use = false;
+		// check if there is a function named fsockopen
+		if ( $use )
+			$use = function_exists( 'fsockopen' );
 
-		return apply_filters('use_fsockopen_transport', $use, $args);
+		// check if openssl is available for SSL transports
+		if  ( $use && $is_ssl ) 
+			$use = extension_loaded( 'openssl' );
+
+		return (bool) apply_filters('use_fsockopen_transport', $use, $args );
 	}
 }
 
@@ -929,11 +930,37 @@
 	 *
 	 * @return boolean False means this class can not be used, true means it can.
 	 */
-	function test($args = array()) {
-		if ( ! function_exists('fopen') || (function_exists('ini_get') && true != ini_get('allow_url_fopen')) )
-			return false;
+	function test( $args = array(), $url = null ) {
+		$is_ssl = !empty( $args['ssl'] );
 
-		return apply_filters('use_streams_transport', true, $args);
+		$scheme = empty($url) ? 'http' : strtolower( parse_url( $url, PHP_URL_SCHEME ) );
+
+		$allowed_schemes = array( 'http', 'https' );
+
+		// check if the requested scheme is allowed 
+		$use = in_array( $scheme, $allowed_schemes );
+
+		// check if the fopen function exists
+		if ( $use )
+			$use = function_exists( 'fopen' );
+
+		// check if url fopen is allowed
+		if ( $use )
+			$use = function_exists( 'ini_get' ) && ini_get( 'allow_url_fopen' );
+
+		// check if requested scheme has a stream wrapper
+		if ( $use )
+			$use = in_array( $scheme, stream_get_wrappers() );
+
+		// check specifically against openssl extension
+		if ( $use && $is_ssl )
+			$use = extension_loaded( 'openssl' );
+
+		// check if streams actually support ssl 
+		if ( $use && $is_ssl )
+			$use = in_array( 'ssl', stream_get_transports() );
+
+		return (bool) apply_filters( 'use_streams_transport', $use, $args, $url );
 	}
 }
 
@@ -1064,8 +1091,13 @@
 				$theBody = http_chunked_decode($theBody);
 		}
 
-		if ( true === $r['decompress'] && true === WP_Http_Encoding::should_decode($theHeaders['headers']) )
-			$theBody = http_inflate( $theBody );
+		if ( true === $r['decompress'] && true === WP_Http_Encoding::should_decode($theHeaders['headers']) ) {
+			if ( http_support( HTTP_SUPPORT_ENCODINGS ) ) {
+				$theBody = http_inflate( $theBody );
+			} else {
+				$theBody = WP_Http_Encoding::decompress( $theBody );
+			}
+		}
 
 		if ( $r['stream'] ) {
 			if ( !WP_DEBUG )
@@ -1097,7 +1129,21 @@
 	 * @return boolean False means this class can not be used, true means it can.
 	 */
 	function test($args = array()) {
-		return apply_filters('use_http_extension_transport', function_exists('http_request'), $args );
+
+		$is_ssl = !empty( $args['ssl'] );
+
+		// check if there is a function named http_support
+		$use = function_exists( 'http_support' );
+
+		// check if there is support for requests
+		if ( $use )
+			$use = http_support( HTTP_SUPPORT_REQUESTS );
+
+		// check if there is support for SSL requests
+		if ( $use && $is_ssl )
+			$use = http_support( HTTP_SUPPORT_SSLREQUESTS );
+
+		return (bool) apply_filters( 'use_http_extension_transport', $use, $args );
 	}
 }
 
@@ -1313,10 +1359,21 @@
 	 * @return boolean False means this class can not be used, true means it can.
 	 */
 	function test($args = array()) {
-		if ( function_exists('curl_init') && function_exists('curl_exec') )
-			return apply_filters('use_curl_transport', true, $args);
 
-		return false;
+		$is_ssl = !empty( $args['ssl'] );
+
+		// check if there is a function named curl_init
+		$use = function_exists( 'curl_init' );
+
+		// check if there is a function named curl_exec
+		if ( $use )
+			$use = function_exists( 'curl_exec' );
+
+		// check if openssl is available for SSL transports
+		if  ( $use && $is_ssl ) 
+			$use = extension_loaded( 'openssl' );
+
+		return (bool) apply_filters( 'use_curl_transport', $use, $args );
 	}
 }
 
