WordPress.org

Make WordPress Core

Changeset 13849


Ignore:
Timestamp:
03/28/10 00:56:43 (5 years ago)
Author:
dd32
Message:

Avoid notices for requests with no body. Also fixes a few race conditions related to headers. Fixes #11872

File:
1 edited

Legend:

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

    r13847 r13849  
    393393     */ 
    394394    function processResponse($strResponse) { 
    395         list($theHeaders, $theBody) = explode("\r\n\r\n", $strResponse, 2); 
    396         return array('headers' => $theHeaders, 'body' => $theBody); 
     395        $res = explode("\r\n\r\n", $strResponse, 2); 
     396         
     397        return array('headers' => isset($res[0]) ? $res[0] : array(), 'body' => isset($res[1]) ? $res[1] : ''); 
    397398    } 
    398399 
     
    427428        // In this case, determine the final HTTP header and parse from there. 
    428429        for ( $i = count($headers)-1; $i >= 0; $i-- ) { 
    429             if ( false === strpos($headers[$i], ':') ) { 
     430            if ( !empty($headers[$i]) && false === strpos($headers[$i], ':') ) { 
    430431                $headers = array_splice($headers, $i); 
    431432                break; 
     
    440441 
    441442            if ( false === strpos($tempheader, ':') ) { 
    442                 list( , $iResponseCode, $strResponseMsg) = explode(' ', $tempheader, 3); 
    443                 $response['code'] = $iResponseCode; 
    444                 $response['message'] = $strResponseMsg; 
     443                list( , $response['code'], $response['message']) = explode(' ', $tempheader, 3); 
    445444                continue; 
    446445            } 
     
    12291228            return array( 'headers' => array(), 'body' => '', 'response' => array('code' => false, 'message' => false), 'cookies' => array() ); 
    12301229 
    1231         list($theHeaders, $theBody) = explode("\r\n\r\n", $strResponse, 2); 
     1230        $headers_body = WP_HTTP::processResponse($strResponse); 
     1231        $theHeaders = $headers_body['headers']; 
     1232        $theBody = $headers_body['body']; 
     1233        unset($headers_body); 
     1234 
    12321235        $theHeaders = WP_Http::processHeaders($theHeaders); 
    12331236 
Note: See TracChangeset for help on using the changeset viewer.