Report curl errors

git-svn-id: http://svn.automattic.com/wordpress/trunk@9185 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2008-10-15 16:35:35 +00:00
parent 3d41b4e4bb
commit 97f11e8f42
2 changed files with 14 additions and 5 deletions

View File

@ -436,6 +436,12 @@ function download_url( $url ) {
$response = wp_remote_get($url);
if ( is_wp_error($response) ) {
fclose($handle);
unlink($tmpfname);
return $response;
}
if ( $response['response']['code'] != '200' ){
fclose($handle);
unlink($tmpfname);

View File

@ -977,7 +977,7 @@ class WP_Http_Curl {
$theResponse = curl_exec( $handle );
if ( $theResponse ) {
if ( !empty($theResponse) ) {
$headerLength = curl_getinfo($handle, CURLINFO_HEADER_SIZE);
$theHeaders = trim( substr($theResponse, 0, $headerLength) );
$theBody = substr( $theResponse, $headerLength );
@ -987,8 +987,11 @@ class WP_Http_Curl {
}
$theHeaders = WP_Http::processHeaders($theHeaders);
} else {
if ( $curl_error = curl_error($handle) )
return new WP_Error('http_request_failed', $curl_error);
if ( in_array( curl_getinfo( $handle, CURLINFO_HTTP_CODE ), array(301, 302) ) )
return new WP_Error('http_request_failed', __('Too many redirects.'));
$theHeaders = array( 'headers' => array() );
$theBody = '';
}