Ticket #16889: 16889.diff
File 16889.diff, 2.4 KB (added by , 12 years ago) |
---|
-
wp-includes/class-http.php
586 586 587 587 return $absolute_path . '/' . ltrim( $path, '/' ); 588 588 } 589 590 /** 591 * Determine if we should perform a redirection 592 * @param $http_code int The HTTP Response code 593 * @param $args mixed The $args passed to the request function 594 * 595 * @since 3.6.0 596 * 597 * @return bool 598 */ 599 public static function should_redirect( $http_code, $args ) { 600 if ( 0 === $args['_redirection'] ) // _redirection: The original requested number of redirections 601 return false; 602 603 if ( $http_code < 300 || $http_code > 399 ) 604 return false; 605 606 return true; 607 } 589 608 } 590 609 591 610 /** … … 798 817 $arrHeaders = WP_Http::processHeaders( $process['headers'] ); 799 818 800 819 // If location is found, then assume redirect and redirect to location. 801 if ( isset($arrHeaders['headers']['location']) && 0 !== $r['_redirection']) {820 if ( isset($arrHeaders['headers']['location']) && WP_HTTP::should_redirect( $arrHeaders['response']['code'], $r ) ) { 802 821 if ( $r['redirection']-- > 0 ) { 803 822 return wp_remote_request( WP_HTTP::make_absolute_url( $arrHeaders['headers']['location'], $url ), $r); 804 823 } else { … … 988 1007 else 989 1008 $processedHeaders = WP_Http::processHeaders($meta['wrapper_data']); 990 1009 991 if ( ! empty( $processedHeaders['headers']['location'] ) && 0 !== $r['_redirection'] ) { // _redirection: The requested number of redirections1010 if ( ! empty( $processedHeaders['headers']['location'] ) && WP_HTTP::should_redirect( $processedHeaders['response']['code'], $r ) ) { 992 1011 if ( $r['redirection']-- > 0 ) { 993 1012 return wp_remote_request( WP_HTTP::make_absolute_url( $processedHeaders['headers']['location'], $url ), $r ); 994 1013 } else { … … 1253 1272 if ( $r['stream'] ) 1254 1273 fclose( $this->stream_handle ); 1255 1274 1256 // See #11305 - When running under safe mode, redirection is disabled above. Handle it manually. 1257 if ( ! empty( $theHeaders['headers']['location'] ) && 0 !== $r['_redirection'] ) { // _redirection: The requested number of redirections 1275 if ( ! empty( $theHeaders['headers']['location'] ) && WP_HTTP::should_redirect( $response['code'], $r ) ) { 1258 1276 if ( $r['redirection']-- > 0 ) { 1259 1277 return wp_remote_request( WP_HTTP::make_absolute_url( $theHeaders['headers']['location'], $url ), $r ); 1260 1278 } else {