| 1 | --- C:/Users/andyc/Documents/My Stuff/WorkshopWeb/wp-includes/class-http-origional.php Tue Mar 13 10:14:27 2012 |
|---|
| 2 | +++ C:/Users/andyc/Documents/My Stuff/WorkshopWeb/wp-includes/class-http.php Wed Mar 14 10:23:06 2012 |
|---|
| 3 | @@ -1042,7 +1042,6 @@ |
|---|
| 4 | curl_setopt( $handle, CURLOPT_SSL_VERIFYHOST, ( $ssl_verify === true ) ? 2 : false ); |
|---|
| 5 | curl_setopt( $handle, CURLOPT_SSL_VERIFYPEER, $ssl_verify ); |
|---|
| 6 | curl_setopt( $handle, CURLOPT_USERAGENT, $r['user-agent'] ); |
|---|
| 7 | - curl_setopt( $handle, CURLOPT_MAXREDIRS, $r['redirection'] ); |
|---|
| 8 | |
|---|
| 9 | switch ( $r['method'] ) { |
|---|
| 10 | case 'HEAD': |
|---|
| 11 | @@ -1074,9 +1073,14 @@ |
|---|
| 12 | curl_setopt( $handle, CURLOPT_FILE, $stream_handle ); |
|---|
| 13 | } |
|---|
| 14 | |
|---|
| 15 | - // The option doesn't work with safe mode or when open_basedir is set. |
|---|
| 16 | + // The curl follow location option doesn't work with safe mode or when open_basedir is set. |
|---|
| 17 | if ( !ini_get('safe_mode') && !ini_get('open_basedir') && 0 !== $r['_redirection'] ) |
|---|
| 18 | - curl_setopt( $handle, CURLOPT_FOLLOWLOCATION, true ); |
|---|
| 19 | + $autoredirect = true; |
|---|
| 20 | + |
|---|
| 21 | + if ($autoredirect) { |
|---|
| 22 | + curl_setopt( $handle, CURLOPT_FOLLOWLOCATION, true ); |
|---|
| 23 | + curl_setopt( $handle, CURLOPT_MAXREDIRS, $r['redirection'] ); |
|---|
| 24 | + } |
|---|
| 25 | |
|---|
| 26 | if ( !empty( $r['headers'] ) ) { |
|---|
| 27 | // cURL expects full header strings in each element |
|---|
| 28 | @@ -1110,10 +1114,11 @@ |
|---|
| 29 | if ( strlen($theResponse) > 0 && ! is_bool( $theResponse ) ) // is_bool: when using $args['stream'], curl_exec will return (bool)true |
|---|
| 30 | $theBody = $theResponse; |
|---|
| 31 | |
|---|
| 32 | - // If no response, and It's not a HEAD request with valid headers returned |
|---|
| 33 | - if ( 0 == strlen($theResponse) && ('HEAD' != $args['method'] || empty($this->headers)) ) { |
|---|
| 34 | - if ( $curl_error = curl_error($handle) ) |
|---|
| 35 | - return new WP_Error('http_request_failed', $curl_error); |
|---|
| 36 | + if ( $curl_error = curl_error($handle) ) |
|---|
| 37 | + return new WP_Error('http_request_failed', $curl_error); |
|---|
| 38 | + |
|---|
| 39 | + // Handle too many redirects with Curl auto redirect |
|---|
| 40 | + if ($autoredirect && 0 == strlen($theResponse) && ('HEAD' != $args['method'] || empty($this->headers)) ) { |
|---|
| 41 | if ( in_array( curl_getinfo( $handle, CURLINFO_HTTP_CODE ), array(301, 302) ) ) |
|---|
| 42 | return new WP_Error('http_request_failed', __('Too many redirects.')); |
|---|
| 43 | } |
|---|
| 44 | @@ -1130,7 +1135,7 @@ |
|---|
| 45 | fclose( $stream_handle ); |
|---|
| 46 | |
|---|
| 47 | // See #11305 - When running under safe mode, redirection is disabled above. Handle it manually. |
|---|
| 48 | - if ( ! empty( $theHeaders['headers']['location'] ) && ( ini_get( 'safe_mode' ) || ini_get( 'open_basedir' ) ) && 0 !== $r['_redirection'] ) { |
|---|
| 49 | + if ( ! empty( $theHeaders['headers']['location'] ) && !$autoredirect ) { |
|---|
| 50 | if ( $r['redirection']-- > 0 ) { |
|---|
| 51 | return $this->request( $theHeaders['headers']['location'], $r ); |
|---|
| 52 | } else { |
|---|