Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Response.php

function Response::setNotModified

Modifies the response so that it conforms to the rules defined for a 304 status code.

This sets the status, removes the body, and discards any headers that MUST NOT be included in 304 responses.

@final

Return value

$this

See also

https://tools.ietf.org/html/rfc2616#section-10.3.5

1 call to Response::setNotModified()
Response::isNotModified in vendor/symfony/http-foundation/Response.php
Determines if the Response validators (ETag, Last-Modified) match a conditional value specified in the Request.

File

vendor/symfony/http-foundation/Response.php, line 1044

Class

Response
Response represents an HTTP response.

Namespace

Symfony\Component\HttpFoundation

Code

public function setNotModified() : static {
    $this->setStatusCode(304);
    $this->setContent(null);
    // remove headers that MUST NOT be included with 304 Not Modified responses
    foreach ([
        'Allow',
        'Content-Encoding',
        'Content-Language',
        'Content-Length',
        'Content-MD5',
        'Content-Type',
        'Last-Modified',
    ] as $header) {
        $this->headers
            ->remove($header);
    }
    return $this;
}
RSS feed
Powered by Drupal