Make WordPress Core

Changeset 24483 for branches/3.5


Ignore:
Timestamp:
06/21/2013 06:22:16 AM (11 years ago)
Author:
nacin
Message:

Merge [23603] and [23608] to the 3.5 branch. This funnels all redirect requests through WP_HTTP::request() via wp_remote_request(). see #23682.

Location:
branches/3.5
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/3.5

  • branches/3.5/wp-includes/class-http.php

    r24481 r24483  
    110110        $r = apply_filters( 'http_request_args', $r, $url );
    111111
    112         // Certain classes decrement this, store a copy of the original value for loop purposes.
    113         $r['_redirection'] = $r['redirection'];
     112        // The transports decrement this, store a copy of the original value for loop purposes.
     113        if ( ! isset( $r['_redirection'] ) )
     114            $r['_redirection'] = $r['redirection'];
    114115
    115116        // Allow plugins to short-circuit the request
     
    783784        if ( isset($arrHeaders['headers']['location']) && 0 !== $r['_redirection'] ) {
    784785            if ( $r['redirection']-- > 0 ) {
    785                 return $this->request( WP_HTTP::make_absolute_url( $arrHeaders['headers']['location'], $url ), $r);
     786                return wp_remote_request( WP_HTTP::make_absolute_url( $arrHeaders['headers']['location'], $url ), $r);
    786787            } else {
    787788                return new WP_Error('http_request_failed', __('Too many redirects.'));
     
    893894                'method' => strtoupper($r['method']),
    894895                'user_agent' => $r['user-agent'],
    895                 'max_redirects' => $r['redirection'] + 1, // See #11557
     896                'max_redirects' => 0, // Follow no redirects
     897                'follow_redirects' => false,
    896898                'protocol_version' => (float) $r['httpversion'],
    897899                'header' => $strHeaders,
     
    966968            $processedHeaders = WP_Http::processHeaders($meta['wrapper_data']);
    967969
    968         // Streams does not provide an error code which we can use to see why the request stream stopped.
    969         // We can however test to see if a location header is present and return based on that.
    970         if ( isset($processedHeaders['headers']['location']) && 0 !== $args['_redirection'] )
    971             return new WP_Error('http_request_failed', __('Too many redirects.'));
     970        if ( ! empty( $processedHeaders['headers']['location'] ) && 0 !== $r['_redirection'] ) { // _redirection: The requested number of redirections
     971            if ( $r['redirection']-- > 0 ) {
     972                return wp_remote_request( WP_HTTP::make_absolute_url( $processedHeaders['headers']['location'], $url ), $r );
     973            } else {
     974                return new WP_Error( 'http_request_failed', __( 'Too many redirects.' ) );
     975            }
     976        }
    972977
    973978        if ( ! empty( $strResponse ) && isset( $processedHeaders['headers']['transfer-encoding'] ) && 'chunked' == $processedHeaders['headers']['transfer-encoding'] )
     
    11861191        if ( ! empty( $theHeaders['headers']['location'] ) && 0 !== $r['_redirection'] ) { // _redirection: The requested number of redirections
    11871192            if ( $r['redirection']-- > 0 ) {
    1188                 return $this->request( WP_HTTP::make_absolute_url( $theHeaders['headers']['location'], $url ), $r );
     1193                return wp_remote_request( WP_HTTP::make_absolute_url( $theHeaders['headers']['location'], $url ), $r );
    11891194            } else {
    11901195                return new WP_Error( 'http_request_failed', __( 'Too many redirects.' ) );
Note: See TracChangeset for help on using the changeset viewer.