title: Werkzeug response too slow
body: <p>I have the following Werkzeug application for returning a file to the client:</p>
  
  <pre><code>from werkzeug.wrappers import Request, Response
  
  @Request.application
  def application(request):    
      fileObj = file(r'C:\test.pdf','rb')
      response = Response( response=fileObj.read() )
      response.headers['content-type'] = 'application/pdf'
      return response
  </code></pre>
  
  <p>The part I want to focus on is this one:</p>
  
  <pre><code>response = Response( response=fileObj.read() )
  </code></pre>
  
  <p>In this case the response takes about 500 ms (<code>C:\test.pdf</code> is a 4 MB file. Web server is in my local machine).</p>
  
  <p>But if I rewrite that line to this:</p>
  
  <pre><code>response = Response()
  response.response = fileObj
  </code></pre>
  
  <p>Now the response takes about 1500 ms. (3 times slower)</p>
  
  <p>And if write it like this:</p>
  
  <pre><code>response = Response()
  response.response = fileObj.read()
  </code></pre>
  
  <p>Now the response takes about 80 seconds (that's right, 80 SECONDS).</p>
  
  <p>Why is there that much difference between the 3 methods?<br>
  And why is the third method sooooo slow?</p>