comparison vendor/symfony/http-foundation/Response.php @ 16:c2387f117808

Routine composer update
author Chris Cannam
date Tue, 10 Jul 2018 15:07:59 +0100
parents 1fec387a4317
children 129ea1e6d783
comparison
equal deleted inserted replaced
15:e200cb7efeb3 16:c2387f117808
19 class Response 19 class Response
20 { 20 {
21 const HTTP_CONTINUE = 100; 21 const HTTP_CONTINUE = 100;
22 const HTTP_SWITCHING_PROTOCOLS = 101; 22 const HTTP_SWITCHING_PROTOCOLS = 101;
23 const HTTP_PROCESSING = 102; // RFC2518 23 const HTTP_PROCESSING = 102; // RFC2518
24 const HTTP_EARLY_HINTS = 103; // RFC8297
24 const HTTP_OK = 200; 25 const HTTP_OK = 200;
25 const HTTP_CREATED = 201; 26 const HTTP_CREATED = 201;
26 const HTTP_ACCEPTED = 202; 27 const HTTP_ACCEPTED = 202;
27 const HTTP_NON_AUTHORITATIVE_INFORMATION = 203; 28 const HTTP_NON_AUTHORITATIVE_INFORMATION = 203;
28 const HTTP_NO_CONTENT = 204; 29 const HTTP_NO_CONTENT = 204;
325 if (headers_sent()) { 326 if (headers_sent()) {
326 return $this; 327 return $this;
327 } 328 }
328 329
329 // headers 330 // headers
330 foreach ($this->headers->allPreserveCaseWithoutCookies() as $name => $values) { 331 foreach ($this->headers->allPreserveCase() as $name => $values) {
331 foreach ($values as $value) { 332 foreach ($values as $value) {
332 header($name.': '.$value, false, $this->statusCode); 333 header($name.': '.$value, false, $this->statusCode);
333 } 334 }
334 } 335 }
335 336
336 // status 337 // status
337 header(sprintf('HTTP/%s %s %s', $this->version, $this->statusCode, $this->statusText), true, $this->statusCode); 338 header(sprintf('HTTP/%s %s %s', $this->version, $this->statusCode, $this->statusText), true, $this->statusCode);
338
339 // cookies
340 foreach ($this->headers->getCookies() as $cookie) {
341 if ($cookie->isRaw()) {
342 setrawcookie($cookie->getName(), $cookie->getValue(), $cookie->getExpiresTime(), $cookie->getPath(), $cookie->getDomain(), $cookie->isSecure(), $cookie->isHttpOnly());
343 } else {
344 setcookie($cookie->getName(), $cookie->getValue(), $cookie->getExpiresTime(), $cookie->getPath(), $cookie->getDomain(), $cookie->isSecure(), $cookie->isHttpOnly());
345 }
346 }
347 339
348 return $this; 340 return $this;
349 } 341 }
350 342
351 /** 343 /**
517 { 509 {
518 return $this->charset; 510 return $this->charset;
519 } 511 }
520 512
521 /** 513 /**
522 * Returns true if the response is worth caching under any circumstance. 514 * Returns true if the response may safely be kept in a shared (surrogate) cache.
523 * 515 *
524 * Responses marked "private" with an explicit Cache-Control directive are 516 * Responses marked "private" with an explicit Cache-Control directive are
525 * considered uncacheable. 517 * considered uncacheable.
526 * 518 *
527 * Responses with neither a freshness lifetime (Expires, max-age) nor cache 519 * Responses with neither a freshness lifetime (Expires, max-age) nor cache
528 * validator (Last-Modified, ETag) are considered uncacheable. 520 * validator (Last-Modified, ETag) are considered uncacheable because there is
521 * no way to tell when or how to remove them from the cache.
522 *
523 * Note that RFC 7231 and RFC 7234 possibly allow for a more permissive implementation,
524 * for example "status codes that are defined as cacheable by default [...]
525 * can be reused by a cache with heuristic expiration unless otherwise indicated"
526 * (https://tools.ietf.org/html/rfc7231#section-6.1)
529 * 527 *
530 * @return bool true if the response is worth caching, false otherwise 528 * @return bool true if the response is worth caching, false otherwise
531 * 529 *
532 * @final since version 3.3 530 * @final since version 3.3
533 */ 531 */