title: symfony huge file download
body: <p>I have controller in Symfony2, which provides file download.</p>
  
  <pre><code>/**
   * @Route("/polynomy/download/{polynomialId}", name="download_polynomial")
   */
  public function polynomialDownloadAction( $polynomialId ) {
      $em = $this-&gt;get('doctrine')-&gt;getManager();
      $polynomial = $em-&gt;getRepository('AppBundle:Polynomial')-&gt;findById($polynomialId);
      $filename = $polynomial-&gt;getFileLocation();
  
      $response = new Response();
      $response-&gt;headers-&gt;set('Cache-Control', 'private');
      $response-&gt;headers-&gt;set('Content-type', mime_content_type($filename));
      $response-&gt;headers-&gt;set('Content-Disposition', 'attachment; filename="'.basename($filename).'";');
      $response-&gt;headers-&gt;set('Content-length', filesize($filename));
      $response-&gt;sendHeaders();
  
      $response-&gt;setContent(readfile($filename));
  
      return $this-&gt;redirect($this-&gt;generateUrl('users_polynomials'));
  }
  </code></pre>
  
  <p>This work just fine for small files (&lt;100MB). But if I want to download file greater than 100MB I get an error (ERR_INVALID_RESPONSE).
  I found, that problem is probably in php function <code>readfile()</code>, which causes memory exhaustion.</p>
  
  <p>Is there a way in Symfony 2.6.1 how to download huge files without memory exhaustion?</p>