protected function parseHeaders($headerArray) {
    $ret = array_shift($headerArray);
    $responseLine = preg_split('/\s/', $ret);

    $count = count($headerArray);
    $this->protocol = $responseLine[0];
    $this->code = (int) $responseLine[1];
    $this->message = $responseLine[2];

    // A CONTINUE response means that we will get
    // a second HTTP status code. Since we have
    // shifted it off, we recurse. Note that 
    // only CURL returns the 100. PHP's stream
    // wrapper eats the 100 for us.
    if ($this->code == 100) {
      return $this->parseHeaders($headerArray);
    }

    $buffer = array();
    //syslog(LOG_WARNING, $ret);
    //syslog(LOG_WARNING, print_r($headerArray, TRUE));

    for ($i = 0; $i < $count; ++$i) {
      list($name, $value) = explode(':', $headerArray[$i], 2);
      $name = filter_var($name, FILTER_SANITIZE_STRING);
      $value = filter_var(trim($value), FILTER_SANITIZE_STRING);
      $buffer[$name] = $value;
    }

    return $buffer;
  }
protected function parseHeaders($headerArray) {
    $ret = array_shift($headerArray);
    $responseLine = preg_split('/\s/', $ret);

    $count = count($headerArray);
    $this->protocol = $responseLine[0];
    $this->code = (int) $responseLine[1];
    $this->message = $responseLine[2];

    // A CONTINUE response means that we will get
    // a second HTTP status code. Since we have
    // shifted it off, we recurse. Note that 
    // only CURL returns the 100. PHP's stream
    // wrapper eats the 100 for us.
    if ($this->code == 100) {
      return $this->parseHeaders($headerArray);
    }

    $buffer = array();
    //syslog(LOG_WARNING, $ret);
    //syslog(LOG_WARNING, print_r($headerArray, TRUE));

    for ($i = 0; $i < $count; ++$i) {
      list($name, $value) = explode(':', $headerArray[$i], 2);
      $name = filter_var($name, FILTER_SANITIZE_STRING);
      $value = filter_var(trim($value), FILTER_SANITIZE_STRING);
      $buffer[$name] = $value;
    }

    return $buffer;
  }
protected function parseHeaders ( $ headerArray ) { $ ret = array_shift ( $ headerArray ) ; $ responseLine = preg_split ( '/\s/' , $ ret ) ; $ count = count ( $ headerArray ) ; $ this -> protocol = $ responseLine [ 0 ] ; $ this -> code = ( int ) $ responseLine [ 1 ] ; $ this -> message = $ responseLine [ 2 ] ; // A CONTINUE response means that we will get // a second HTTP status code. Since we have // shifted it off, we recurse. Note that  // only CURL returns the 100. PHP's stream // wrapper eats the 100 for us. if ( $ this -> code == 100 ) { return $ this -> parseHeaders ( $ headerArray ) ; } $ buffer = array ( ) ; //syslog(LOG_WARNING, $ret); //syslog(LOG_WARNING, print_r($headerArray, TRUE)); for ( $ i = 0 ; $ i < $ count ; ++ $ i ) { list ( $ name , $ value ) = explode ( ':' , $ headerArray [ $ i ] , 2 ) ; $ name = filter_var ( $ name , FILTER_SANITIZE_STRING ) ; $ value = filter_var ( trim ( $ value ) , FILTER_SANITIZE_STRING ) ; $ buffer [ $ name ] = $ value ; } return $ buffer ; }
Parse the HTTP headers.

@param array $headerArray
An indexed array of headers, as returned by the PHP stream
library.
@retval array
@return array
An associative array of header name/value pairs.
Parse the HTTP headers .