Make WordPress Core

Ticket #37456: 37456.diff

File 37456.diff, 4.2 KB (added by dd32, 9 years ago)

One method of respecting the data format

  • src/wp-includes/class-http.php

    class WP_Http { 
    303303                $options = array(
    304304                        'timeout' => $r['timeout'],
    305305                        'useragent' => $r['user-agent'],
    306306                        'blocking' => $r['blocking'],
    307307                        'hooks' => new Requests_Hooks(),
    308308                );
    309309
    310310                // Ensure redirects follow browser behaviour.
    311311                $options['hooks']->register( 'requests.before_redirect', array( get_class(), 'browser_redirect_compatibility' ) );
    312312
    313313                if ( $r['stream'] ) {
    314314                        $options['filename'] = $r['filename'];
    315315                }
    316316                if ( empty( $r['redirection'] ) ) {
    317317                        $options['follow_redirects'] = false;
    318                 }
    319                 else {
     318                } else {
    320319                        $options['redirects'] = $r['redirection'];
    321320                }
    322321
    323322                // Use byte limit, if we can
    324323                if ( isset( $r['limit_response_size'] ) ) {
    325324                        $options['max_bytes'] = $r['limit_response_size'];
    326325                }
    327326
    328327                // If we've got cookies, use them
    329328                if ( ! empty( $r['cookies'] ) ) {
    330329                        $options['cookies'] = $r['cookies'];
    331330                }
    332331
    333332                // SSL certificate handling
    334333                if ( ! $r['sslverify'] ) {
    335334                        $options['verify'] = false;
    336                 }
    337                 else {
     335                } else {
    338336                        $options['verify'] = $r['sslcertificates'];
    339337                }
    340338
     339                // Pass through the data format settings for args if supplied
     340                if ( isset( $r['data_format'] ) ) {
     341                        $options['data_format'] = $r['data_format'];
     342                }
     343
    341344                /**
    342345                 * Filters whether SSL should be verified for non-local requests.
    343346                 *
    344347                 * @since 2.8.0
    345348                 *
    346349                 * @param bool $ssl_verify Whether to verify the SSL connection. Default true.
    347350                 */
    348351                $options['verify'] = apply_filters( 'https_ssl_verify', $options['verify'] );
    349352
    350353                // Check for proxies.
    351354                $proxy = new WP_HTTP_Proxy();
    352355                if ( $proxy->is_enabled() && $proxy->send_through_proxy( $url ) ) {
    353356                        $options['proxy'] = new Requests_Proxy_HTTP( $proxy->host() . ':' . $proxy->port() );
    354357
    355358                        if ( $proxy->use_authentication() ) {
    class WP_Http { 
    524527        }
    525528
    526529        /**
    527530         * Uses the POST HTTP method.
    528531         *
    529532         * Used for sending data that is expected to be in the body.
    530533         *
    531534         * @access public
    532535         * @since 2.7.0
    533536         *
    534537         * @param string       $url  The request URL.
    535538         * @param string|array $args Optional. Override the defaults.
    536539         * @return array|WP_Error Array containing 'headers', 'body', 'response', 'cookies', 'filename'. A WP_Error instance upon error
    537540         */
    538541        public function post($url, $args = array()) {
    539                 $defaults = array('method' => 'POST');
     542                $defaults = array(
     543                        'method' => 'POST',
     544                        'data_format' => 'body',
     545                );
    540546                $r = wp_parse_args( $args, $defaults );
    541547                return $this->request($url, $r);
    542548        }
    543549
    544550        /**
    545551         * Uses the GET HTTP method.
    546552         *
    547553         * Used for sending data that is expected to be in the body.
    548554         *
    549555         * @access public
    550556         * @since 2.7.0
    551557         *
    552558         * @param string $url The request URL.
    553559         * @param string|array $args Optional. Override the defaults.
    554560         * @return array|WP_Error Array containing 'headers', 'body', 'response', 'cookies', 'filename'. A WP_Error instance upon error
    555561         */
    556562        public function get($url, $args = array()) {
    557                 $defaults = array('method' => 'GET');
     563                $defaults = array(
     564                        'method' => 'GET',
     565                        'data_format' => 'query',
     566                );
    558567                $r = wp_parse_args( $args, $defaults );
    559568                return $this->request($url, $r);
    560569        }
    561570
    562571        /**
    563572         * Uses the HEAD HTTP method.
    564573         *
    565574         * Used for sending data that is expected to be in the body.
    566575         *
    567576         * @access public
    568577         * @since 2.7.0
    569578         *
    570579         * @param string $url The request URL.
    571580         * @param string|array $args Optional. Override the defaults.
    572581         * @return array|WP_Error Array containing 'headers', 'body', 'response', 'cookies', 'filename'. A WP_Error instance upon error
    573582         */
    574583        public function head($url, $args = array()) {
    575                 $defaults = array('method' => 'HEAD');
     584                $defaults = array(
     585                        'method' => 'GET',
     586                        'data_format' => 'query',
     587                );
    576588                $r = wp_parse_args( $args, $defaults );
    577589                return $this->request($url, $r);
    578590        }
    579591
    580592        /**
    581593         * Parses the responses and splits the parts into headers and body.
    582594         *
    583595         * @access public
    584596         * @static
    585597         * @since 2.7.0
    586598         *
    587599         * @param string $strResponse The full response string
    588600         * @return array Array with 'headers' and 'body' keys.
    589601         */
    590602        public static function processResponse($strResponse) {