Symfony\Component\HttpFoundation\Response::setNotModified PHP Method

setNotModified() public method

This sets the status, removes the body, and discards any headers that MUST NOT be included in 304 responses.
See also: http://tools.ietf.org/html/rfc2616#section-10.3.5
public setNotModified ( ) : Response
return Response
    public function setNotModified()
    {
        $this->setStatusCode(304);
        $this->setContent(null);

        // remove headers that MUST NOT be included with 304 Not Modified responses
        foreach (array('Allow', 'Content-Encoding', 'Content-Language', 'Content-Length', 'Content-MD5', 'Content-Type', 'Last-Modified') as $header) {
            $this->headers->remove($header);
        }

        return $this;
    }

Usage Example

 public function testSetNotModified()
 {
     $response = new Response();
     $modified = $response->setNotModified();
     $this->assertObjectHasAttribute('headers', $modified);
     $this->assertObjectHasAttribute('content', $modified);
     $this->assertObjectHasAttribute('version', $modified);
     $this->assertObjectHasAttribute('statusCode', $modified);
     $this->assertObjectHasAttribute('statusText', $modified);
     $this->assertObjectHasAttribute('charset', $modified);
     $this->assertEquals(304, $modified->getStatusCode());
 }
All Usage Examples Of Symfony\Component\HttpFoundation\Response::setNotModified