Make WordPress Core


Ignore:
Timestamp:
08/01/2008 10:31:57 PM (16 years ago)
Author:
ryan
Message:

Fixes process headers for fopen header return, fixes HTTP extension response array. Props santosj. see #4779

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/http.php

    r8522 r8523  
    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.
    321      *
    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.
     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.
    324319     *
    325320     * @access public
     
    331326     */
    332327    function processHeaders($headers) {
    333         if ( is_array($headers) )
    334             return $headers;
    335 
    336         $headers = explode("\n", str_replace(array("\r\n", "\r"), "\n", $headers) );
     328        if ( is_string($headers) )
     329            $headers = explode("\n", str_replace(array("\r\n", "\r"), "\n", $headers) );
    337330
    338331        $response = array('code' => 0, 'message' => '');
     
    343336                continue;
    344337
     338           
    345339            if ( false === strpos($tempheader, ':') ) {
    346340                list( , $iResponseCode, $strResponseMsg) = explode(' ', $tempheader, 3);
     
    561555            $theHeaders = $http_response_header;
    562556        }
     557
     558        fclose($handle);
     559
    563560        $processedHeaders = WP_Http::processHeaders($theHeaders);
    564561
    565         fclose($handle);
    566562        return array('headers' => $processedHeaders['headers'], 'body' => $strResponse, 'response' => $processedHeaders['response']);
    567563    }
     
    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);
Note: See TracChangeset for help on using the changeset viewer.