3 * Zend Framework (http://framework.zend.com/)
5 * @link http://github.com/zendframework/zf2 for the canonical source repository
6 * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
7 * @license http://framework.zend.com/license/new-bsd New BSD License
10 namespace Zend\Http\PhpEnvironment
;
12 use Zend\Http\Header\MultipleHeaderInterface
;
13 use Zend\Http\Response
as HttpResponse
;
16 * HTTP Response for current PHP environment
18 class Response
extends HttpResponse
21 * The current used version
22 * (The value will be detected on getVersion)
31 protected $contentSent = false;
34 * Return the HTTP version for this response
37 * @see \Zend\Http\AbstractMessage::getVersion()
39 public function getVersion()
41 if (!$this->version
) {
42 $this->version
= $this->detectVersion();
44 return $this->version
;
48 * Detect the current used protocol version.
49 * If detection failed it falls back to version 1.0.
53 protected function detectVersion()
55 if (isset($_SERVER['SERVER_PROTOCOL']) && $_SERVER['SERVER_PROTOCOL'] == 'HTTP/1.1') {
56 return self
::VERSION_11
;
59 return self
::VERSION_10
;
65 public function headersSent()
67 return headers_sent();
73 public function contentSent()
75 return $this->contentSent
;
83 public function sendHeaders()
85 if ($this->headersSent()) {
89 $status = $this->renderStatusLine();
92 /** @var \Zend\Http\Header\HeaderInterface $header */
93 foreach ($this->getHeaders() as $header) {
94 if ($header instanceof MultipleHeaderInterface
) {
95 header($header->toString(), false);
98 header($header->toString());
101 $this->headersSent
= true;
110 public function sendContent()
112 if ($this->contentSent()) {
116 echo $this->getContent();
117 $this->contentSent
= true;
126 public function send()