WordPress.org

Make WordPress Core

Ticket #4779: 4779.r8523.diff

File 4779.r8523.diff, 3.9 KB (added by santosj, 10 years ago)

Last set of fixes that I can find and from testing. Need more live testing and test cases. Based off of r8523

  • http.php

     
    8888                static $working_transport;
    8989
    9090                if ( is_null($working_transport) ) {
    91                         if ( true === WP_Http_Streams::test() )
     91                        if ( true === WP_Http_ExtHttp::test() )
     92                                $working_transport = new WP_Http_ExtHttp();
     93                        else if ( true === WP_Http_Curl::test() )
     94                                $working_transport = new WP_Http_Curl();
     95                        else if ( true === WP_Http_Streams::test() )
    9296                                $working_transport = new WP_Http_Streams();
    93                         else if ( true === WP_Http_ExtHttp::test() )
    94                                 $working_transport = new WP_Http_ExtHttp();
    9597                        else if ( true === WP_Http_Fopen::test() )
    9698                                $working_transport = new WP_Http_Fopen();
    9799                        else if ( true === WP_Http_Fsockopen::test() )
     
    119121                static $working_transport;
    120122
    121123                if ( is_null($working_transport) ) {
    122                         if ( true === WP_Http_Streams::test() )
     124                        if ( true === WP_Http_ExtHttp::test() )
     125                                $working_transport = new WP_Http_ExtHttp();
     126                        else if ( true === WP_Http_Streams::test() )
    123127                                $working_transport = new WP_Http_Streams();
    124                         else if ( true === WP_Http_ExtHttp::test() )
    125                                 $working_transport = new WP_Http_ExtHttp();
    126128                        else if ( true === WP_Http_Fsockopen::test() )
    127129                                $working_transport = new WP_Http_Fsockopen();
    128130                }
     
    193195                if ( ! isset($headers['user-agent']) || ! isset($headers['User-Agent']) )
    194196                        $headers['user-agent'] = $r['user-agent'];
    195197
    196                 if ( is_null($body) || count($headers) > 1 )
     198                if ( is_null($body) )
    197199                        $transport = WP_Http::_getTransport();
    198200                else
    199201                        $transport = WP_Http::_postTransport();
    200202
    201                 return $transport->request($url, $headers, $body, $r);
     203                return $transport->request($url, $r, $headers, $body);
    202204        }
    203205
    204206        /**
     
    218220        function post($url, $args = array(), $headers = null, $body = null) {
    219221                $defaults = array('method' => 'POST');
    220222                $r = wp_parse_args( $args, $defaults );
    221                 return $this->request($url, $headers, $body, $r);
     223                return $this->request($url, $r, $headers, $body);
    222224        }
    223225
    224226        /**
     
    238240        function get($url, $args = array(), $headers = null, $body = null) {
    239241                $defaults = array('method' => 'GET');
    240242                $r = wp_parse_args( $args, $defaults );
    241                 return $this->request($url, $headers, $body, $r);
     243                return $this->request($url, $r, $headers, $body);
    242244        }
    243245
    244246        /**
     
    694696         *
    695697         * @param string $url
    696698         * @param str|array $args Optional. Override the defaults.
    697          * @param string|array $headers Optional. Either the header string or array of Header name and value pairs. Expects sanitized.
     699         * @param array $headers Optional. Either the header string or array of Header name and value pairs. Expects sanitized.
    698700         * @param string $body Optional. The body that should be sent. Expected to be already processed.
    699701         * @return array 'headers', 'body', and 'response' keys.
    700702         */
     
    936938function wp_remote_request($url, $args = array(), $headers = null, $body = null) {
    937939        $objFetchSite = _wp_http_get_object();
    938940
    939         return $objFetchSite->request($url, $headers, $body, $args);
     941        return $objFetchSite->request($url, $args, $headers, $body);
    940942}
    941943
    942944/**
     
    955957function wp_remote_get($url, $args = array(), $headers = null, $body = null) {
    956958        $objFetchSite = _wp_http_get_object();
    957959
    958         return $objFetchSite->get($url, $headers, $body, $args);
     960        return $objFetchSite->get($url, $args, $headers, $body);
    959961}
    960962
    961963/**
     
    974976function wp_remote_post($url, $args = array(), $headers = null, $body = null) {
    975977        $objFetchSite = _wp_http_get_object();
    976978
    977         return $objFetchSite->post($url, $headers, $body, $args);
     979        return $objFetchSite->post($url, $args, $headers, $body);
    978980}
    979981
    980982/**
     
    993995function wp_remote_head($url, $args = array(), $headers = null, $body = null) {
    994996        $objFetchSite = _wp_http_get_object();
    995997
    996         return $objFetchSite->head($url, $headers, $body, $args);
     998        return $objFetchSite->head($url, $args, $headers, $body);
    997999}
    9981000
    9991001/**