### 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)
@@ -745,20 +745,29 @@
 	 * @static
 	 * @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;
+	function test( $args = array(), $url = null ) {
+		$is_ssl = isset( $args['ssl'] ) && $args['ssl'];
 
-		$is_ssl = isset($args['ssl']) && $args['ssl'];
+		$scheme = empty( $url ) ? 'http' : strtolower( parse_url( $url, PHP_URL_SCHEME ) );
 
-		if ( ! $is_ssl && function_exists( 'fsockopen' ) )
-			$use = true;
-		elseif ( $is_ssl && extension_loaded('openssl') && function_exists( 'fsockopen' ) )
-			$use = true;
-		else
-			$use = false;
+		$allowed_schemes = array( 'http', 'https' );
 
-		return apply_filters('use_fsockopen_transport', $use, $args);
+		// check if the requested scheme is allowed 
+		$use = in_array( $scheme, $allowed_schemes );
+
+		// check if fsockopen has been disabled for 12 hours
+		if ( $use )
+			$use = ( $option = get_option( 'disable_fsockopen', 0 ) ) && time() - $option < 43200; // 43200 = 12 hours 
+
+		// check if there is a function named fsockopen
+		if ( $use )
+			$use = function_exists( 'fsockopen' );
+
+		// check if openssl is available for SSL transports
+		if  ( $use && $is_ssl ) 
+			$use = extension_loaded( 'openssl' );
+
+		return apply_filters('use_fsockopen_transport', $use, $args, $url);
 	}
 }
 
@@ -929,11 +938,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 = '' ) {
+		$is_ssl = isset( $args['ssl'] ) && $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 );
 	}
 }
 
@@ -1096,8 +1131,22 @@
 	 *
 	 * @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 );
+	function test($args = array(), $url = null) {
+
+		$is_ssl = isset( $args['ssl'] ) && $args['ssl'];
+
+		$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 there is a function named curl_init
+		if ( $use )
+			$use = function_exists( 'http_request' );
+
+		return (bool) apply_filters( 'use_http_extension_transport', $use, $args, $url );
 	}
 }
 
@@ -1312,11 +1361,30 @@
 	 *
 	 * @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);
+	function test($args = array(), $url = null) {
 
-		return false;
+		$is_ssl = isset( $args['ssl'] ) && $args['ssl'];
+
+		$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 there is a function named curl_init
+		if ( $use )
+			$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, $url );
 	}
 }
 
