WordPress 4.6.2
[autoinstalls/wordpress.git] / wp-includes / Requests / Transport / fsockopen.php
index e9170f417ceb2d424be89700ebf23ae4cca0a75d..21cb56d5eccab6cf65dbbb230c3515661a30ff25 100644 (file)
@@ -70,7 +70,9 @@ class Requests_Transport_fsockopen implements Requests_Transport {
                // HTTPS support
                if (isset($url_parts['scheme']) && strtolower($url_parts['scheme']) === 'https') {
                        $remote_socket = 'ssl://' . $host;
-                       $url_parts['port'] = 443;
+                       if (!isset($url_parts['port'])) {
+                               $url_parts['port'] = 443;
+                       }
 
                        $context_options = array(
                                'verify_peer' => true,
@@ -97,6 +99,7 @@ class Requests_Transport_fsockopen implements Requests_Transport {
                        }
 
                        if (isset($options['verifyname']) && $options['verifyname'] === false) {
+                               $context_options['verify_peer_name'] = false;
                                $verifyname = false;
                        }
 
@@ -171,7 +174,7 @@ class Requests_Transport_fsockopen implements Requests_Transport {
                if (!isset($case_insensitive_headers['Host'])) {
                        $out .= sprintf('Host: %s', $url_parts['host']);
 
-                       if ($url_parts['port'] !== 80) {
+                       if (( 'http' === strtolower($url_parts['scheme']) && $url_parts['port'] !== 80 ) || ( 'https' === strtolower($url_parts['scheme']) && $url_parts['port'] !== 443 )) {
                                $out .= ':' . $url_parts['port'];
                        }
                        $out .= "\r\n";