yii\web\Response::getHeaders PHP Method

getHeaders() public method

The header collection contains the currently registered HTTP headers.
public getHeaders ( ) : HeaderCollection
return HeaderCollection the header collection
    public function getHeaders()
    {
        if ($this->_headers === null) {
            $this->_headers = new HeaderCollection();
        }
        return $this->_headers;
    }

Usage Example

 /**
  * Formats the specified response.
  * @param Response $response the response to be formatted.
  */
 public function format($response)
 {
     $response->getHeaders()->set('Content-Type', $this->contentType);
     if ($this->filename !== null) {
         $response->getHeaders()->set('Content-Disposition', "attachment; filename=\"{$this->filename}\"");
     }
     $response->content = Yii::$app->{$this->converter}->convert($response->data, $this->options);
 }
All Usage Examples Of yii\web\Response::getHeaders