WordPress.org

Make WordPress Core

Changeset 23607


Ignore:
Timestamp:
03/04/13 04:47:39 (14 months ago)
Author:
dd32
Message:

WP_HTTP: Return error responses from cURL for non-blocking requests. Contrary to popular belief, cURL's non-blocking requests are not exact non-blocking, we still wait for cURL to make the request before returning, so making this change aids in development debugging. Props SergeyBiryukov Fixes #23310

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/class-http.php

    r23605 r23607  
    12071207        if ( ! $r['blocking'] ) { 
    12081208            curl_exec( $handle ); 
     1209 
     1210            if ( $curl_error = curl_error( $handle ) ) { 
     1211                curl_close( $handle ); 
     1212                return new WP_Error( 'http_request_failed', $curl_error ); 
     1213            } 
     1214            if ( in_array( curl_getinfo( $handle, CURLINFO_HTTP_CODE ), array( 301, 302 ) ) ) { 
     1215                curl_close( $handle ); 
     1216                return new WP_Error( 'http_request_failed', __( 'Too many redirects.' ) ); 
     1217            } 
     1218 
    12091219            curl_close( $handle ); 
    12101220            return array( 'headers' => array(), 'body' => '', 'response' => array('code' => false, 'message' => false), 'cookies' => array() ); 
     
    12201230        // If no response 
    12211231        if ( 0 == strlen( $theBody ) && empty( $theHeaders['headers'] ) ) { 
    1222             if ( $curl_error = curl_error( $handle ) ) 
     1232            if ( $curl_error = curl_error( $handle ) ) { 
     1233                curl_close( $handle ); 
    12231234                return new WP_Error( 'http_request_failed', $curl_error ); 
    1224             if ( in_array( curl_getinfo( $handle, CURLINFO_HTTP_CODE ), array( 301, 302 ) ) ) 
     1235            } 
     1236            if ( in_array( curl_getinfo( $handle, CURLINFO_HTTP_CODE ), array( 301, 302 ) ) ) { 
     1237                curl_close( $handle ); 
    12251238                return new WP_Error( 'http_request_failed', __( 'Too many redirects.' ) ); 
     1239            } 
    12261240        } 
    12271241 
Note: See TracChangeset for help on using the changeset viewer.