public function getHeaders()
    {
        if (!is_object($this->_headers)) {
            $headerCollection = new HeaderCollection();
            if (is_array($this->_headers)) {
                foreach ($this->_headers as $name => $value) {
                    if (is_int($name)) {
                        // parse raw header :
                        $rawHeader = $value;
                        if (strpos($rawHeader, 'HTTP/') === 0) {
                            $parts = explode(' ', $rawHeader, 3);
                            $headerCollection->add('http-code', $parts[1]);
                        } elseif (($separatorPos = strpos($rawHeader, ':')) !== false) {
                            $name = strtolower(trim(substr($rawHeader, 0, $separatorPos)));
                            $value = trim(substr($rawHeader, $separatorPos + 1));
                            $headerCollection->add($name, $value);
                        } else {
                            $headerCollection->add('raw', $rawHeader);
                        }
                    } else {
                        $headerCollection->set($name, $value);
                    }
                }
            }
            $this->_headers = $headerCollection;
        }
        return $this->_headers;
    }
public function getHeaders()
    {
        if (!is_object($this->_headers)) {
            $headerCollection = new HeaderCollection();
            if (is_array($this->_headers)) {
                foreach ($this->_headers as $name => $value) {
                    if (is_int($name)) {
                        // parse raw header :
                        $rawHeader = $value;
                        if (strpos($rawHeader, 'HTTP/') === 0) {
                            $parts = explode(' ', $rawHeader, 3);
                            $headerCollection->add('http-code', $parts[1]);
                        } elseif (($separatorPos = strpos($rawHeader, ':')) !== false) {
                            $name = strtolower(trim(substr($rawHeader, 0, $separatorPos)));
                            $value = trim(substr($rawHeader, $separatorPos + 1));
                            $headerCollection->add($name, $value);
                        } else {
                            $headerCollection->add('raw', $rawHeader);
                        }
                    } else {
                        $headerCollection->set($name, $value);
                    }
                }
            }
            $this->_headers = $headerCollection;
        }
        return $this->_headers;
    }
public function getHeaders ( ) { if ( ! is_object ( $ this -> _headers ) ) { $ headerCollection = new HeaderCollection ( ) ; if ( is_array ( $ this -> _headers ) ) { foreach ( $ this -> _headers as $ name => $ value ) { if ( is_int ( $ name ) ) { // parse raw header : $ rawHeader = $ value ; if ( strpos ( $ rawHeader , 'HTTP/' ) === 0 ) { $ parts = explode ( ' ' , $ rawHeader , 3 ) ; $ headerCollection -> add ( 'http-code' , $ parts [ 1 ] ) ; } elseif ( ( $ separatorPos = strpos ( $ rawHeader , ':' ) ) !== false ) { $ name = strtolower ( trim ( substr ( $ rawHeader , 0 , $ separatorPos ) ) ) ; $ value = trim ( substr ( $ rawHeader , $ separatorPos + 1 ) ) ; $ headerCollection -> add ( $ name , $ value ) ; } else { $ headerCollection -> add ( 'raw' , $ rawHeader ) ; } } else { $ headerCollection -> set ( $ name , $ value ) ; } } } $ this -> _headers = $ headerCollection ; } return $ this -> _headers ; }
Returns the header collection.
The header collection contains the HTTP headers associated with HTTP message.
@return HeaderCollection the header collection
Returns the header collection . The header collection contains the HTTP headers associated with HTTP message .