getResponse() public method

Handle a request for a file
public getResponse ( Request $request ) : Response
$request Elgg\Http\Request HTTP request
return Symfony\Component\HttpFoundation\Response
コード例 #1
0
 /**
  * @group FileService
  */
 public function testResponseHeadersMatchFileAttributesForAttachmentUrls()
 {
     $file = new \Elgg\FileService\File();
     $file->setFile($this->file);
     $file->setDisposition('attachment');
     $file->bindSession(true);
     $request = $this->createRequest($file);
     $response = $this->handler->getResponse($request);
     $this->assertEquals('text/plain', $response->headers->get('Content-Type'));
     $filesize = filesize($this->file->getFilenameOnFilestore());
     $this->assertEquals($filesize, $response->headers->get('Content-Length'));
     $this->assertContains('attachment', $response->headers->get('Content-Disposition'));
     $this->assertEquals('"' . filemtime($this->file->getFilenameOnFilestore()) . '"', $response->headers->get('Etag'));
 }