WordPress.org

Make WordPress Core

Ticket #11305: http.php.diff

File http.php.diff, 1.1 KB (added by calin, 4 years ago)
  • http.php

     
    297297 
    298298                if ( has_action('http_api_debug') ) 
    299299                        do_action('http_api_debug', $transports, 'transports_list'); 
    300  
    301300                $response = array( 'headers' => array(), 'body' => '', 'response' => array('code' => false, 'message' => false), 'cookies' => array() ); 
    302301                foreach ( (array) $transports as $transport ) { 
    303302                        $response = $transport->request($url, $r); 
    304  
     303                        if (ini_get('open_basedir')) { 
     304                                $r['redirection']--; 
     305                                $url = $response['headers']['location']; 
     306                                if ($r['redirection'] < 1 && $response['headers']['location']) $response = new WP_Error('http_request_failed',__('Too many redirects.')); 
     307                                if ( ! is_wp_error($response) && !empty ($url)) { 
     308                                        $url = $response['headers']['location']; 
     309                                        $response = $this->request($url, array('redirection' => $r['redirection'])); 
     310                                } 
     311                        } 
    305312                        if ( has_action('http_api_debug') ) 
    306313                                do_action( 'http_api_debug', $response, 'response', get_class($transport) ); 
    307314