public function Response::setEtag

Sets the ETag value.

@api

Parameters

string|null $etag The ETag unique identifier or null to remove the header:

Boolean $weak Whether you want a weak ETag or not:

Return value

Response

2 calls to Response::setEtag()
BinaryFileResponse::setAutoEtag in drupal/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/BinaryFileResponse.php
Automatically sets the ETag header according to the checksum of the file.
Response::setCache in drupal/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Response.php
Sets the response's cache headers (validation and/or expiration).

File

drupal/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Response.php, line 867

Class

Response
Response represents an HTTP response.

Namespace

Symfony\Component\HttpFoundation

Code

public function setEtag($etag = null, $weak = false) {
  if (null === $etag) {
    $this->headers
      ->remove('Etag');
  }
  else {
    if (0 !== strpos($etag, '"')) {
      $etag = '"' . $etag . '"';
    }
    $this->headers
      ->set('ETag', (true === $weak ? 'W/' : '') . $etag);
  }
  return $this;
}