public function serveAssetAction(Request $request, $asset_name) { try { $asset = new Asset($this->getAssetPath($asset_name)); //grab the regexps to test against from the config file for this asset $response = new Response(); $response->setContent($asset->getContent()); $response->headers->set('Content-Type', $asset->getMimeType()); $response->headers->set('X-Generated-By', get_class($this)); $response->headers->set('Content-Length', $asset->getContentLength()); return $response; } catch (\Exception $e) { return new Response($e->getMessage(), 404); } }
public function testGetEmptyContentLength() { $a = new Asset(); $this->assertSame(0, $a->getContentLength()); }