Make WordPress Core

Changeset 9051


Ignore:
Timestamp:
10/02/2008 12:32:21 AM (16 years ago)
Author:
ryan
Message:

Error checking for HTTP requests. Props jacobsantos. see #7793

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/update-links.php

    r9011 r9051  
    3939$response = wp_remote_get('http://api.pingomatic.com/updated-batch/', $options);
    4040
     41if ( is_wp_error( $response ) )
     42    wp_die(__('Request Failed.'));
     43
    4144if ( $response['response']['code'] != 200 )
    4245    wp_die(__('Request Failed.'));
  • trunk/wp-includes/comment.php

    r9039 r9051  
    13171317    );
    13181318
    1319     wp_remote_post($trackback_url, $options);
     1319    $response = wp_remote_post($trackback_url, $options);
     1320   
     1321    if ( is_wp_error( $response ) )
     1322        return;
    13201323
    13211324    $tb_url = addslashes( $trackback_url );
  • trunk/wp-includes/functions.php

    r9025 r9051  
    10401040    $response = wp_remote_request($url, $options);
    10411041
     1042    if ( is_wp_error( $response ) )
     1043        return false;
     1044
    10421045    $headers = wp_remote_retrieve_headers( $response );
    10431046    if ( false == $file_path )
     
    10731076function wp_get_http_headers( $url, $deprecated = false ) {
    10741077    $response = wp_remote_head( $url );
     1078
     1079    if ( is_wp_error( $response ) )
     1080        return false;
     1081
    10751082    return wp_remote_retrieve_headers( $response );
    10761083}
     
    12411248 *
    12421249 * @param string $uri URI/URL of web page to retrieve.
    1243  * @return string HTTP content.
     1250 * @return bool|string HTTP content. False on failure.
    12441251 */
    12451252function wp_remote_fopen( $uri ) {
    1246     // parse url() should not be used for validation of URLs.
    1247     // Keeping anyway, since the Filter extension is not available on all servers.
    12481253    $parsed_url = @parse_url( $uri );
    12491254
     
    12551260
    12561261    $response = wp_remote_get( $uri, $options );
     1262
     1263    if ( is_wp_error( $response ) )
     1264        return false;
    12571265
    12581266    return $response['body'];
Note: See TracChangeset for help on using the changeset viewer.