Changeset 51825 for trunk/src/wp-includes/class-wp-http-streams.php
- Timestamp:
- 09/19/2021 04:59:35 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-http-streams.php
r51298 r51825 52 52 WP_Http::buildCookieHeader( $parsed_args ); 53 53 54 $ arrURL= parse_url( $url );55 56 $connect_host = $ arrURL['host'];57 58 $secure_transport = ( 'ssl' === $ arrURL['scheme'] || 'https' === $arrURL['scheme'] );59 if ( ! isset( $ arrURL['port'] ) ) {60 if ( 'ssl' === $ arrURL['scheme'] || 'https' === $arrURL['scheme'] ) {61 $ arrURL['port']= 443;62 $secure_transport = true;54 $parsed_url = parse_url( $url ); 55 56 $connect_host = $parsed_url['host']; 57 58 $secure_transport = ( 'ssl' === $parsed_url['scheme'] || 'https' === $parsed_url['scheme'] ); 59 if ( ! isset( $parsed_url['port'] ) ) { 60 if ( 'ssl' === $parsed_url['scheme'] || 'https' === $parsed_url['scheme'] ) { 61 $parsed_url['port'] = 443; 62 $secure_transport = true; 63 63 } else { 64 $ arrURL['port'] = 80;64 $parsed_url['port'] = 80; 65 65 } 66 66 } 67 67 68 68 // Always pass a path, defaulting to the root in cases such as http://example.com. 69 if ( ! isset( $ arrURL['path'] ) ) {70 $ arrURL['path'] = '/';69 if ( ! isset( $parsed_url['path'] ) ) { 70 $parsed_url['path'] = '/'; 71 71 } 72 72 73 73 if ( isset( $parsed_args['headers']['Host'] ) || isset( $parsed_args['headers']['host'] ) ) { 74 74 if ( isset( $parsed_args['headers']['Host'] ) ) { 75 $ arrURL['host'] = $parsed_args['headers']['Host'];75 $parsed_url['host'] = $parsed_args['headers']['Host']; 76 76 } else { 77 $ arrURL['host'] = $parsed_args['headers']['host'];77 $parsed_url['host'] = $parsed_args['headers']['host']; 78 78 } 79 79 unset( $parsed_args['headers']['Host'], $parsed_args['headers']['host'] ); … … 115 115 'ssl' => array( 116 116 'verify_peer' => $ssl_verify, 117 // 'CN_match' => $ arrURL['host'], // This is handled by self::verify_ssl_certificate().117 // 'CN_match' => $parsed_url['host'], // This is handled by self::verify_ssl_certificate(). 118 118 'capture_peer_cert' => $ssl_verify, 119 119 'SNI_enabled' => true, … … 145 145 } else { 146 146 // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged 147 $handle = @stream_socket_client( $connect_host . ':' . $ arrURL['port'], $connection_error, $connection_error_str, $connect_timeout, STREAM_CLIENT_CONNECT, $context );147 $handle = @stream_socket_client( $connect_host . ':' . $parsed_url['port'], $connection_error, $connection_error_str, $connect_timeout, STREAM_CLIENT_CONNECT, $context ); 148 148 } 149 149 … … 155 155 $handle = stream_socket_client( 'tcp://' . $proxy->host() . ':' . $proxy->port(), $connection_error, $connection_error_str, $connect_timeout, STREAM_CLIENT_CONNECT, $context ); 156 156 } else { 157 $handle = stream_socket_client( $connect_host . ':' . $ arrURL['port'], $connection_error, $connection_error_str, $connect_timeout, STREAM_CLIENT_CONNECT, $context );157 $handle = stream_socket_client( $connect_host . ':' . $parsed_url['port'], $connection_error, $connection_error_str, $connect_timeout, STREAM_CLIENT_CONNECT, $context ); 158 158 } 159 159 } … … 170 170 // Verify that the SSL certificate is valid for this request. 171 171 if ( $secure_transport && $ssl_verify && ! $proxy->is_enabled() ) { 172 if ( ! self::verify_ssl_certificate( $handle, $ arrURL['host'] ) ) {172 if ( ! self::verify_ssl_certificate( $handle, $parsed_url['host'] ) ) { 173 173 return new WP_Error( 'http_request_failed', __( 'The SSL certificate for the host could not be verified.' ) ); 174 174 } … … 180 180 $requestPath = $url; 181 181 } else { 182 $requestPath = $ arrURL['path'] . ( isset( $arrURL['query'] ) ? '?' . $arrURL['query'] : '' );182 $requestPath = $parsed_url['path'] . ( isset( $parsed_url['query'] ) ? '?' . $parsed_url['query'] : '' ); 183 183 } 184 184 … … 187 187 $include_port_in_host_header = ( 188 188 ( $proxy->is_enabled() && $proxy->send_through_proxy( $url ) ) || 189 ( 'http' === $ arrURL['scheme'] && 80 != $arrURL['port'] ) ||190 ( 'https' === $ arrURL['scheme'] && 443 != $arrURL['port'] )189 ( 'http' === $parsed_url['scheme'] && 80 != $parsed_url['port'] ) || 190 ( 'https' === $parsed_url['scheme'] && 443 != $parsed_url['port'] ) 191 191 ); 192 192 193 193 if ( $include_port_in_host_header ) { 194 $strHeaders .= 'Host: ' . $ arrURL['host'] . ':' . $arrURL['port'] . "\r\n";194 $strHeaders .= 'Host: ' . $parsed_url['host'] . ':' . $parsed_url['port'] . "\r\n"; 195 195 } else { 196 $strHeaders .= 'Host: ' . $ arrURL['host'] . "\r\n";196 $strHeaders .= 'Host: ' . $parsed_url['host'] . "\r\n"; 197 197 } 198 198
Note: See TracChangeset
for help on using the changeset viewer.