‪TYPO3CMS  10.4
HtmlResponse.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
16 namespace ‪TYPO3\CMS\Core\Http;
17 
26 {
34  public function ‪__construct($content, $status = 200, array ‪$headers = [])
35  {
36  ‪$body = new ‪Stream('php://temp', 'wb+');
37  ‪$body->write($content);
38  ‪$body->rewind();
39  parent::__construct(‪$body, $status, ‪$headers);
40 
41  // Ensure that text/html header is set, if Content-Type was not set before
42  if (!$this->‪hasHeader('Content-Type')) {
43  $this->headers['Content-Type'][] = 'text/html; charset=utf-8';
44  $this->lowercasedHeaderNames['content-type'] = 'Content-Type';
45  }
46  }
47 }
‪TYPO3\CMS\Core\Http\Message\hasHeader
‪bool hasHeader($name)
Definition: Message.php:123
‪TYPO3\CMS\Core\Http\HtmlResponse\__construct
‪__construct($content, $status=200, array $headers=[])
Definition: HtmlResponse.php:34
‪TYPO3\CMS\Core\Http\Response
Definition: Response.php:30
‪TYPO3\CMS\Core\Http\Stream
Definition: Stream.php:29
‪TYPO3\CMS\Core\Http\Message\$body
‪StreamInterface $body
Definition: Message.php:51
‪TYPO3\CMS\Core\Http\Message\$headers
‪array $headers
Definition: Message.php:40
‪TYPO3\CMS\Core\Http\HtmlResponse
Definition: HtmlResponse.php:26
‪TYPO3\CMS\Core\Http
Definition: AbstractApplication.php:18