Make WordPress Core

Ticket #17490: 17490.diff

File 17490.diff, 1.2 KB (added by sivel, 14 years ago)
  • wp-includes/class-http.php

     
    10741074                }
    10751075
    10761076                // The option doesn't work with safe mode or when open_basedir is set.
    1077                 if ( !ini_get('safe_mode') && !ini_get('open_basedir') && 0 !== $r['_redirection'] )
     1077                if ( !ini_get('safe_mode') && !ini_get('open_basedir') && 0 !== $r['_redirection'] && $r['method'] !== 'POST' )
    10781078                        curl_setopt( $handle, CURLOPT_FOLLOWLOCATION, true );
    10791079
    10801080                if ( !empty( $r['headers'] ) ) {
     
    11031103                }
    11041104
    11051105                $theResponse = curl_exec( $handle );
     1106
    11061107                $theBody = '';
    11071108                $theHeaders = WP_Http::processHeaders( $this->headers );
    11081109
     1110                if ( in_array( curl_getinfo( $handle, CURLINFO_HTTP_CODE ), array( 301, 302) ) && $r['method'] == 'POST' ) {
     1111                        $r['method'] = 'GET';
     1112                        $r['body'] = '';
     1113                        $r['headers'] = '';
     1114                        $url = $theHeaders['headers']['location'];
     1115                        return wp_remote_get($url, $r);
     1116                }
     1117
    11091118                if ( strlen($theResponse) > 0 && ! is_bool( $theResponse ) ) // is_bool: when using $args['stream'], curl_exec will return (bool)true
    11101119                        $theBody = $theResponse;
    11111120