27 #require_once "Zend/Http/Header/Exception/InvalidArgumentException.php"; 32 #require_once "Zend/Http/Header/Exception/RuntimeException.php"; 37 #require_once "Zend/Http/Header/HeaderValue.php"; 126 public static function fromString($headerLine, $bypassHeaderFieldName =
false)
128 list(
$name,
$value) = explode(
': ', $headerLine, 2);
131 if (strtolower(
$name) !==
'set-cookie') {
135 $multipleHeaders = preg_split(
'#(?<!Sun|Mon|Tue|Wed|Thu|Fri|Sat),\s*#',
$value);
137 foreach ($multipleHeaders as $headerLine) {
138 $header =
new self();
139 $keyValuePairs = preg_split(
'#;\s*#', $headerLine);
140 foreach ($keyValuePairs as $keyValue) {
141 if (strpos($keyValue,
'=')) {
142 list($headerKey, $headerValue) = preg_split(
'#=\s*#', $keyValue, 2);
144 $headerKey = $keyValue;
149 if ($header->getName() === NULL) {
150 $header->setName($headerKey);
151 $header->setValue($headerValue);
156 switch (str_replace(array(
'-',
'_'),
'', strtolower($headerKey))) {
157 case 'expires' : $header->setExpires($headerValue);
break;
158 case 'domain' : $header->setDomain($headerValue);
break;
159 case 'path' : $header->setPath($headerValue);
break;
160 case 'secure' : $header->setSecure(
true);
break;
161 case 'httponly': $header->setHttponly(
true);
break;
162 case 'version' : $header->setVersion((
int) $headerValue);
break;
163 case 'maxage' : $header->setMaxAge((
int) $headerValue);
break;
168 $headers[] = $header;
170 return count($headers) == 1 ? array_pop($headers) : $headers;
191 $this->type =
'Cookie';
249 if (strpos(
$value,
'"')!==
false) {
250 $value =
'"'.urlencode(str_replace(
'"',
'',
$value)).
'"';
258 $fieldValue .=
'; Version=' .
$version;
263 $fieldValue .=
'; Max-Age=' .
$maxAge;
268 $fieldValue .=
'; Expires=' .
$expires;
273 $fieldValue .=
'; Domain=' .
$domain;
278 $fieldValue .=
'; Path=' .
$path;
282 $fieldValue .=
'; Secure';
286 $fieldValue .=
'; HttpOnly';
298 if (preg_match(
"/[=,; \t\r\n\013\014]/",
$name)) {
400 if ($this->expires ==
null) {
406 return gmdate(
'D, d-M-Y H:i:s', $this->expires) .
' GMT';
493 if (is_int($this->expires) && $this->expires < $now) {
507 return ($this->expires ===
null);
520 if ($this->secure && $this->
isSecure()!==$isSecure) {
542 foreach ($headers as $header) {
545 'The SetCookie multiple header implementation can only accept an array of SetCookie headers' 548 $headerLine .=
', ' . $header->getFieldValue();
$block setTitle( 'CMS Block Title') -> setIdentifier('fixture_block') ->setContent('< h1 >Fixture Block Title</h1 >< a href=" store url</a><p> Config value
elseif(isset( $params[ 'redirect_parent']))