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 / Header / Connection.php
blob39333baaf9573fad091e1f47d156cef070e8a2c7
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\Header;
12 /**
13 * Connection Header
15 * @link http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.10
17 class Connection implements HeaderInterface
19 const CONNECTION_CLOSE = 'close';
20 const CONNECTION_KEEP_ALIVE = 'keep-alive';
22 /**
23 * Value of this header
25 * @var string
27 protected $value = self::CONNECTION_KEEP_ALIVE;
29 /**
30 * @param $headerLine
31 * @return Connection
32 * @throws Exception\InvalidArgumentException
34 public static function fromString($headerLine)
36 $header = new static();
38 list($name, $value) = GenericHeader::splitHeaderLine($headerLine);
40 // check to ensure proper header type for this factory
41 if (strtolower($name) !== 'connection') {
42 throw new Exception\InvalidArgumentException('Invalid header line for Connection string: "' . $name . '"');
45 $header->setValue(trim($value));
47 return $header;
51 /**
52 * Set Connection header to define persistent connection
54 * @param bool $flag
55 * @return Connection
57 public function setPersistent($flag)
59 if ((bool) $flag === true) {
60 $this->value = self::CONNECTION_KEEP_ALIVE;
61 } else {
62 $this->value = self::CONNECTION_CLOSE;
64 return $this;
67 /**
68 * Get whether this connection is persistent
70 * @return bool
72 public function isPersistent()
74 return ($this->value === self::CONNECTION_KEEP_ALIVE);
77 /**
78 * Set arbitrary header value
79 * RFC allows any token as value, 'close' and 'keep-alive' are commonly used
81 * @param string $value
82 * @return Connection
84 public function setValue($value)
86 $this->value = strtolower($value);
87 return $this;
91 /**
92 * Connection header name
94 * @return string
96 public function getFieldName()
98 return 'Connection';
102 * Connection header value
104 * @return string
106 public function getFieldValue()
108 return $this->value;
112 * Return header line
114 * @return string
116 public function toString()
118 return 'Connection: ' . $this->getFieldValue();