Ticket #10624: 10624.diff
| File 10624.diff, 2.2 KB (added by , 17 years ago) |
|---|
-
wp-includes/http.php
599 599 ); 600 600 601 601 $r = wp_parse_args( $args, $defaults ); 602 if ( ! isset($r['max-redirects']) ) 603 $r['max-redirects'] = $r['redirection']; 602 604 603 605 if ( isset($r['headers']['User-Agent']) ) { 604 606 $r['user-agent'] = $r['headers']['User-Agent']; … … 726 728 return new WP_Error('http_request_failed', $arrHeaders['response']['code'] . ': ' . $arrHeaders['response']['message']); 727 729 728 730 // If location is found, then assume redirect and redirect to location. 729 if ( isset($arrHeaders['headers']['location']) ) {731 if ( isset($arrHeaders['headers']['location']) && 0 != $r['max-redirects'] ) { 730 732 if ( $r['redirection']-- > 0 ) { 731 733 return $this->request($arrHeaders['headers']['location'], $r); 732 734 } else { … … 1303 1305 curl_setopt( $handle, CURLOPT_HEADER, false ); 1304 1306 1305 1307 // The option doesn't work with safe mode or when open_basedir is set. 1306 if ( !ini_get('safe_mode') && !ini_get('open_basedir') )1308 if ( 0 != $r['redirection'] && !ini_get('safe_mode') && !ini_get('open_basedir') ) 1307 1309 curl_setopt( $handle, CURLOPT_FOLLOWLOCATION, true ); 1308 1310 1309 1311 if ( !empty( $r['headers'] ) ) { … … 1334 1336 $theResponse = curl_exec( $handle ); 1335 1337 1336 1338 if ( !empty($theResponse) ) { 1337 $parts = explode("\r\n\r\n", $theResponse);1338 1339 1339 $headerLength = curl_getinfo($handle, CURLINFO_HEADER_SIZE); 1340 1340 $theHeaders = trim( substr($theResponse, 0, $headerLength) ); 1341 1341 $theBody = substr( $theResponse, $headerLength ); … … 1345 1345 } 1346 1346 $theHeaders = WP_Http::processHeaders($theHeaders); 1347 1347 } else { 1348 if ( in_array( curl_getinfo( $handle, CURLINFO_HTTP_CODE ), array(301, 302) ) ) 1349 return new WP_Error('http_request_failed', __('Too many redirects.')); 1348 1350 if ( $curl_error = curl_error($handle) ) 1349 1351 return new WP_Error('http_request_failed', $curl_error); 1350 if ( in_array( curl_getinfo( $handle, CURLINFO_HTTP_CODE ), array(301, 302) ) )1351 return new WP_Error('http_request_failed', __('Too many redirects.'));1352 1352 1353 1353 $theHeaders = array( 'headers' => array(), 'cookies' => array() ); 1354 1354 $theBody = '';