WordPress.org

Make WordPress Core

Ticket #4779: 4779.r8522.diff

File 4779.r8522.diff, 2.4 KB (added by santosj, 6 years ago)

Fixes process headers for fopen header return, fixes HTTP extension response array.

  • http.php

     
    313313        /** 
    314314         * Transform header string into an array. 
    315315         * 
    316          * If an array is given, then it will be immediately passed through with no 
    317          * changes. This is to prevent overhead in processing headers that don't 
    318          * need to be processed. That and it is unknown what kind of effect 
    319          * processing the array will have since there is no checking done on whether 
    320          * ':' does not exist within the array string. 
     316         * If an array is given then it is assumed to be raw header data with 
     317         * numeric keys with the headers as the values. No headers must be passed 
     318         * that were already processed. 
    321319         * 
    322          * Checking could be added, but it is easier and faster to just passed the 
    323          * array through and assume that it has already been processed. 
    324          * 
    325320         * @access public 
    326321         * @static 
    327322         * @since 2.7 
     
    330325         * @return array Processed string headers  
    331326         */ 
    332327        function processHeaders($headers) { 
    333                 if ( is_array($headers) ) 
    334                         return $headers; 
     328                if ( is_string($headers) ) 
     329                        $headers = explode("\n", str_replace(array("\r\n", "\r"), "\n", $headers) ); 
    335330 
    336                 $headers = explode("\n", str_replace(array("\r\n", "\r"), "\n", $headers) ); 
    337  
    338331                $response = array('code' => 0, 'message' => ''); 
    339332 
    340333                $newheaders = array(); 
     
    342335                        if ( empty($tempheader) ) 
    343336                                continue; 
    344337 
     338                         
    345339                        if ( false === strpos($tempheader, ':') ) { 
    346340                                list( , $iResponseCode, $strResponseMsg) = explode(' ', $tempheader, 3); 
    347341                                $response['code'] = $iResponseCode; 
     
    560554                } else { 
    561555                        $theHeaders = $http_response_header; 
    562556                } 
    563                 $processedHeaders = WP_Http::processHeaders($theHeaders); 
    564557 
    565558                fclose($handle); 
     559 
     560                $processedHeaders = WP_Http::processHeaders($theHeaders); 
     561 
    566562                return array('headers' => $processedHeaders['headers'], 'body' => $strResponse, 'response' => $processedHeaders['response']); 
    567563        } 
    568564 
     
    762758                $theHeaders = WP_Http::processHeaders($theHeaders); 
    763759 
    764760                $theResponse = array(); 
    765                 $theResponse['response']['code'] = $info['response_code']; 
    766                 $theResponse['response']['message'] = get_status_header_desc($info['response_code']); 
     761                $theResponse['code'] = $info['response_code']; 
     762                $theResponse['message'] = get_status_header_desc($info['response_code']); 
    767763 
    768764                return array('headers' => $theHeaders['headers'], 'body' => $theBody, 'response' => $theResponse); 
    769765        }