Added the zend framework 2 library, the path is specified in line no.26 in zend_modul...
[openemr.git] / interface / modules / zend_modules / library / Zend / Http / PhpEnvironment / Response.php
blobf0400927a65e79a4ab5f29b434e7d707c5c1eb54
1 <?php
2 /**
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
8 */
10 namespace Zend\Http\PhpEnvironment;
12 use Zend\Http\Header\MultipleHeaderInterface;
13 use Zend\Http\Response as HttpResponse;
15 /**
16 * HTTP Response for current PHP environment
18 class Response extends HttpResponse
20 /**
21 * The current used version
22 * (The value will be detected on getVersion)
24 * @var null|string
26 protected $version;
28 /**
29 * @var bool
31 protected $contentSent = false;
33 /**
34 * Return the HTTP version for this response
36 * @return string
37 * @see \Zend\Http\AbstractMessage::getVersion()
39 public function getVersion()
41 if (!$this->version) {
42 $this->version = $this->detectVersion();
44 return $this->version;
47 /**
48 * Detect the current used protocol version.
49 * If detection failed it falls back to version 1.0.
51 * @return string
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;
62 /**
63 * @return bool
65 public function headersSent()
67 return headers_sent();
70 /**
71 * @return bool
73 public function contentSent()
75 return $this->contentSent;
78 /**
79 * Send HTTP headers
81 * @return Response
83 public function sendHeaders()
85 if ($this->headersSent()) {
86 return $this;
89 $status = $this->renderStatusLine();
90 header($status);
92 /** @var \Zend\Http\Header\HeaderInterface $header */
93 foreach ($this->getHeaders() as $header) {
94 if ($header instanceof MultipleHeaderInterface) {
95 header($header->toString(), false);
96 continue;
98 header($header->toString());
101 $this->headersSent = true;
102 return $this;
106 * Send content
108 * @return Response
110 public function sendContent()
112 if ($this->contentSent()) {
113 return $this;
116 echo $this->getContent();
117 $this->contentSent = true;
118 return $this;
122 * Send HTTP response
124 * @return Response
126 public function send()
128 $this->sendHeaders()
129 ->sendContent();
130 return $this;