Ticket #11468: 11468.diff
File 11468.diff, 3.5 KB (added by , 15 years ago) |
---|
-
wp-includes/http.php
678 678 if ( false === $handle ) 679 679 return new WP_Error('http_request_failed', $iError . ': ' . $strError); 680 680 681 stream_set_timeout($handle, $r['timeout'] ); 681 $timeout = (int) floor( $r['timeout'] ); 682 $utimeout = $timeout == $r['timeout'] ? 0 : 1000000 * $r['timeout'] % 1000000; 683 stream_set_timeout( $handle, $timeout, $utimeout ); 682 684 683 685 if ( $proxy->is_enabled() && $proxy->send_through_proxy( $url ) ) //Some proxies require full URL in this field. 684 686 $requestPath = $url; … … 834 836 if (! $handle) 835 837 return new WP_Error('http_request_failed', sprintf(__('Could not open handle for fopen() to %s'), $url)); 836 838 837 stream_set_timeout($handle, $r['timeout'] ); 839 $timeout = (int) floor( $r['timeout'] ); 840 $utimeout = $timeout == $r['timeout'] ? 0 : 1000000 * $r['timeout'] % 1000000; 841 stream_set_timeout( $handle, $timeout, $utimeout ); 838 842 839 843 if ( ! $r['blocking'] ) { 840 844 fclose($handle); … … 1007 1011 if ( ! $handle) 1008 1012 return new WP_Error('http_request_failed', sprintf(__('Could not open handle for fopen() to %s'), $url)); 1009 1013 1010 // WordPress supports PHP 4.3, which has this function. Removed sanity checking for1011 // performance reasons.1012 stream_set_timeout( $handle, $r['timeout']);1014 $timeout = (int) floor( $r['timeout'] ); 1015 $utimeout = $timeout == $r['timeout'] ? 0 : 1000000 * $r['timeout'] % 1000000; 1016 stream_set_timeout( $handle, $timeout, $utimeout ); 1013 1017 1014 1018 if ( ! $r['blocking'] ) { 1015 1019 stream_set_blocking($handle, 0); … … 1141 1145 elseif ( ! $is_local ) 1142 1146 $ssl_verify = apply_filters('https_ssl_verify', $ssl_verify); 1143 1147 1148 $r['timeout'] = (int) ceil( $r['timeout'] ); 1149 1144 1150 $options = array( 1145 1151 'timeout' => $r['timeout'], 1146 1152 'connecttimeout' => $r['timeout'], … … 1255 1261 // Construct Cookie: header if any cookies are set. 1256 1262 WP_Http::buildCookieHeader( $r ); 1257 1263 1258 // cURL extension will sometimes fail when the timeout is less than 1 as it may round down1259 // to 0, which gives it unlimited timeout.1260 if ( $r['timeout'] > 0 && $r['timeout'] < 1 )1261 $r['timeout'] = 1;1262 1263 1264 $handle = curl_init(); 1264 1265 1265 1266 // cURL offers really easy proxy support. … … 1292 1293 elseif ( ! $is_local ) 1293 1294 $ssl_verify = apply_filters('https_ssl_verify', $ssl_verify); 1294 1295 1296 1297 // CURLOPT_TIMEOUT and CURLOPT_CONNECTTIMEOUT expect integers. Have to use ceil since 1298 // a value of 0 will allow an ulimited timeout. 1299 // Use _MS if available. 1300 if ( defined( 'CURLOPT_TIMEOUT_MS' ) ) { 1301 $timeout_ms = (int) ceil( 1000 * $r['timeout'] ); 1302 curl_setopt( $handle, CURLOPT_CONNECTTIMEOUT_MS, $timeout_ms ); 1303 curl_setopt( $handle, CURLOPT_TIMEOUT_MS, $timeout_ms ); 1304 } else { 1305 $timeout = (int) ceil( $r['timeout'] ); 1306 curl_setopt( $handle, CURLOPT_CONNECTTIMEOUT, $timeout ); 1307 curl_setopt( $handle, CURLOPT_TIMEOUT, $timeout ); 1308 } 1309 1295 1310 curl_setopt( $handle, CURLOPT_URL, $url); 1296 1311 curl_setopt( $handle, CURLOPT_RETURNTRANSFER, true ); 1297 1312 curl_setopt( $handle, CURLOPT_SSL_VERIFYHOST, $ssl_verify ); 1298 1313 curl_setopt( $handle, CURLOPT_SSL_VERIFYPEER, $ssl_verify ); 1299 1314 curl_setopt( $handle, CURLOPT_USERAGENT, $r['user-agent'] ); 1300 curl_setopt( $handle, CURLOPT_CONNECTTIMEOUT, $r['timeout'] );1301 curl_setopt( $handle, CURLOPT_TIMEOUT, $r['timeout'] );1302 1315 curl_setopt( $handle, CURLOPT_MAXREDIRS, $r['redirection'] ); 1303 1316 1304 1317 switch ( $r['method'] ) {