示例#1
0
 /**
  * @param HttpResponseInterface $response
  * @return $this
  */
 protected function applyHttpHeaders(HttpResponseInterface $response)
 {
     if (!empty($this->httpResponseCode)) {
         $response->setHttpResponseCode($this->httpResponseCode);
     }
     if ($this->statusHeaderCode) {
         $response->setStatusHeader($this->statusHeaderCode, $this->statusHeaderVersion, $this->statusHeaderPhrase);
     }
     if (!empty($this->headers)) {
         foreach ($this->headers as $headerData) {
             $response->setHeader($headerData['name'], $headerData['value'], $headerData['replace']);
         }
     }
     return $this;
 }
示例#2
0
文件: Text.php 项目: mage2pro/core
 /**
  * 2016-07-04
  * @override
  * @see \Magento\Framework\Controller\AbstractResult::render()
  * https://github.com/magento/magento2/blob/2.1.0/lib/internal/Magento/Framework/Controller/AbstractResult.php#L109-L113
  * @param IHttp|Http $response
  * @return $this
  */
 protected function render(IHttp $response)
 {
     $response->setBody($this->_body);
     df_response_content_type(implode('; ', [$this->contentType(), 'charset=utf-8']), $response);
     return $this;
 }