Update wp_get_http() to handle redirections on HEAD requests. Un-deprecate $red header to track total redirections. See #10624
git-svn-id: https://develop.svn.wordpress.org/trunk@13151 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
c4da5360d4
commit
a498c11da0
@ -1236,15 +1236,15 @@ function do_enclose( $content, $post_ID ) {
|
||||
*
|
||||
* @param string $url URL to fetch.
|
||||
* @param string|bool $file_path Optional. File path to write request to.
|
||||
* @param bool $deprecated Deprecated. Not used.
|
||||
* @param int $red (private) The number of Redirects followed, Upon 5 being hit, returns false.
|
||||
* @return bool|string False on failure and string of headers if HEAD request.
|
||||
*/
|
||||
function wp_get_http( $url, $file_path = false, $deprecated = false ) {
|
||||
if ( !empty( $deprecated ) )
|
||||
_deprecated_argument( __FUNCTION__, '2.7' );
|
||||
|
||||
function wp_get_http( $url, $file_path = false, $red = 1 ) {
|
||||
@set_time_limit( 60 );
|
||||
|
||||
if ( $red > 5 )
|
||||
return false;
|
||||
|
||||
$options = array();
|
||||
$options['redirection'] = 5;
|
||||
|
||||
@ -1261,6 +1261,11 @@ function wp_get_http( $url, $file_path = false, $deprecated = false ) {
|
||||
$headers = wp_remote_retrieve_headers( $response );
|
||||
$headers['response'] = $response['response']['code'];
|
||||
|
||||
// WP_HTTP no longer follows redirects for HEAD requests.
|
||||
if ( 'HEAD' == $options['method'] && in_array($headers['response'], array(301, 302)) && isset( $headers['location'] ) ) {
|
||||
return wp_get_http( $headers['location'], $file_path, ++$red );
|
||||
}
|
||||
|
||||
if ( false == $file_path )
|
||||
return $headers;
|
||||
|
||||
@ -4032,4 +4037,4 @@ function get_file_data( $file, $default_headers, $context = '' ) {
|
||||
function _search_terms_tidy($t) {
|
||||
return trim($t, "\"'\n\r ");
|
||||
}
|
||||
?>
|
||||
?>
|
Loading…
Reference in New Issue
Block a user