From 31e805261c3363bc47ce8871ce783a93eaf8e328 Mon Sep 17 00:00:00 2001 From: ryan Date: Fri, 1 May 2009 23:53:38 +0000 Subject: [PATCH] Send valid host when using WP_Http_Fsockopen over SSL. Props mdawaffe. fixes #9699 git-svn-id: http://svn.automattic.com/wordpress/trunk@11154 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/http.php | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/wp-includes/http.php b/wp-includes/http.php index e12fd02795..63bbcc49f0 100644 --- a/wp-includes/http.php +++ b/wp-includes/http.php @@ -604,11 +604,13 @@ class WP_Http_Fsockopen { $arrURL = parse_url($url); + $fsockopen_host = $arrURL['host']; + $secure_transport = false; - if ( ! isset($arrURL['port']) ) { - if ( ($arrURL['scheme'] == 'ssl' || $arrURL['scheme'] == 'https') && extension_loaded('openssl') ) { - $arrURL['host'] = 'ssl://' . $arrURL['host']; + if ( ! isset( $arrURL['port'] ) ) { + if ( ( $arrURL['scheme'] == 'ssl' || $arrURL['scheme'] == 'https' ) && extension_loaded('openssl') ) { + $fsockopen_host = "ssl://$fsockopen_host"; $arrURL['port'] = 443; $secure_transport = true; } else { @@ -627,14 +629,14 @@ class WP_Http_Fsockopen { if ( !defined('WP_DEBUG') || ( defined('WP_DEBUG') && false === WP_DEBUG ) ) { if ( $proxy->is_enabled() && $proxy->send_through_proxy( $url ) ) - $handle = @fsockopen($proxy->host(), $proxy->port(), $iError, $strError, $r['timeout'] ); + $handle = @fsockopen( $proxy->host(), $proxy->port(), $iError, $strError, $r['timeout'] ); else - $handle = @fsockopen($arrURL['host'], $arrURL['port'], $iError, $strError, $r['timeout'] ); + $handle = @fsockopen( $fsockopen_host, $arrURL['port'], $iError, $strError, $r['timeout'] ); } else { if ( $proxy->is_enabled() && $proxy->send_through_proxy( $url ) ) - $handle = fsockopen($proxy->host(), $proxy->port(), $iError, $strError, $r['timeout'] ); + $handle = fsockopen( $proxy->host(), $proxy->port(), $iError, $strError, $r['timeout'] ); else - $handle = fsockopen($arrURL['host'], $arrURL['port'], $iError, $strError, $r['timeout'] ); + $handle = fsockopen( $fsockopen_host, $arrURL['port'], $iError, $strError, $r['timeout'] ); } $endDelay = time(); @@ -2001,7 +2003,7 @@ function wp_remote_retrieve_header(&$response, $header) { * @return string the response code. Empty string on incorrect parameter given. */ function wp_remote_retrieve_response_code(&$response) { - if ( is_wp_error($response) ||! isset($response['response']) || ! is_array($response['response'])) + if ( is_wp_error($response) || ! isset($response['response']) || ! is_array($response['response'])) return ''; return $response['response']['code'];