Make WordPress Core

Changeset 10281


Ignore:
Timestamp:
12/30/2008 10:45:51 PM (16 years ago)
Author:
ryan
Message:

HTTP API debug and action for curl object. Props jacobsantos. see #8727

File:
1 edited

Legend:

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

    r10211 r10281  
    3030 * requirement, it will be easy to add the static keyword to the code. It is not
    3131 * as easy to convert a function to a method after enough code uses the old way.
     32 *
     33 * Debugging includes several actions, which pass different variables for
     34 * debugging the HTTP API.
     35 *
     36 * <strong>http_transport_get_debug</strong> - gives working, nonblocking, and
     37 * blocking transports.
     38 *
     39 * <strong>http_transport_post_debug</strong> - gives working, nonblocking, and
     40 * blocking transports.
    3241 *
    3342 * @package WordPress
     
    115124        }
    116125
     126        if( has_filter('http_transport_get_debug') )
     127            do_action('http_transport_get_debug', $working_transport, $blocking_transport, $nonblocking_transport);
     128
    117129        if ( isset($args['blocking']) && !$args['blocking'] )
    118130            return $nonblocking_transport;
     
    157169        }
    158170
     171        if( has_filter('http_transport_post_debug') )
     172            do_action('http_transport_post_debug', $working_transport, $blocking_transport, $nonblocking_transport);
     173
    159174        if ( isset($args['blocking']) && !$args['blocking'] )
    160175            return $nonblocking_transport;
     
    258273        }
    259274
     275        if( has_action('http_api_debug') )
     276            do_action('http_api_debug', $transports, 'transports_list');
     277
    260278        $response = array( 'headers' => array(), 'body' => '', 'response' => array('code', 'message') );
    261279        foreach( (array) $transports as $transport ) {
    262280            $response = $transport->request($url, $r);
    263281
    264             if( !is_wp_error($response) )
     282            if( has_action('http_api_debug') )
     283                do_action( 'http_api_debug', $response, 'response', get_class($transport) );
     284
     285            if( ! is_wp_error($response) )
    265286                return $response;
    266287        }
     
    410431            if ( $hasChunk ) {
    411432                if ( empty($match[1]) ) {
    412                     return new WP_Error('http_chunked_decode', __('Does not appear to be chunked encoded or body is malformed.') );
     433                    return $body;
    413434                }
    414435
     
    427448                }
    428449            } else {
    429                 return new WP_Error('http_chunked_decode', __('Does not appear to be chunked encoded or body is malformed.') );
     450                return $body;
    430451            }
    431452        } while ( false === $done );
     
    10191040        else
    10201041            curl_setopt( $handle, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1 );
     1042
     1043        do_action_ref_array( 'http_api_curl', &$handle );
    10211044
    10221045        if ( ! $r['blocking'] ) {
Note: See TracChangeset for help on using the changeset viewer.