Make WordPress Core

Ticket #37456: 37456.2.diff

File 37456.2.diff, 1.9 KB (added by dd32, 9 years ago)

The better method of setting data_format=body.

  • 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                // All non-GET/HEAD requests should put the args in the form body
     340                if ( 'HEAD' != $type && 'GET' != $type ) {
     341                        $options['data_format'] = 'body';
     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() ) {