title: PHP Downloaded file is 0 bytes in firefox puzzle
body: <p>I've been running this test on my website for days now and it still baffles me.</p>
  
  <p>I have a zip file on my server. Within the zip file is a single text file that contains the phrase "this is a test".</p>
  
  <p>In my file api.php, I have the following code:</p>
  
  <pre><code>&lt;?php
  
  $originalFileName = "test.zip";
  
  header("content-encoding: none");
  header("Content-Type: application/zip");  
  header("Content-Disposition: attachment; filename=\"" . "test.zip" . "\"");
  header("Content-Length: " . filesize($originalFileName));
  
  readfile($originalFileName);
  
  ?&gt;
  </code></pre>
  
  <p>When I visit the api.php file in firefox. It prompts to download "test.zip" with a file size of 128 bytes.</p>
  
  <p>When I click save. It creates the file on my desktop, but the file is 0 bytes in size and is empty.</p>
  
  <p>If I visit the url using the direct IP address i.e. <a href="http://192.0.0.1/api.php" rel="nofollow noreferrer">http://192.0.0.1/api.php</a></p>
  
  <p>It downloads the zip file and contains the text file as its suppose to.</p>
  
  <p>The domain is under cloudflare with the caching disabled and developer mode on so it shouldn't be that different.</p>
  
  <p>I used firefox's dev tools to copy the responses from the domain request and the ip request</p>
  
  <p>Domain request - This makes the 0 byte empty zip file</p>
  
  <pre><code>HTTP/1.1 200 OK
  Date: Sat, 01 Jun 2019 10:15:22 GMT
  content-disposition: attachment; filename="test.zip"
  Content-Length: 128
  Content-Type: application/zip
  content-encoding: none
  Connection: keep-alive
  X-Powered-By: PHP/7.2.16
  Vary: User-Agent
  Alt-Svc: h2=":443"; ma=60
  CF-RAY: 4e006d0d4e615629-ORD
  Server: cloudflare
  
  UEsDBBQAAAAAADEcwU7q5x4NDgAAAA4AAAAIAAAAdGVzdC50eHR0aGlzIGlzIGEgdGVzdFBLAQIUABQAAAAAADEcwU7q5x4NDgAAAA4AAAAIAAAAAAAAAAEAIAAAAAAAAAB0ZXN0LnR4dFBLBQYAAAAAAQABADYAAAA0AAAAAAA=
  </code></pre>
  
  <p>Direct IP request - This makes the 128 byte zip file </p>
  
  <pre><code>HTTP/1.1 200 OK
  Date: Sat, 01 Jun 2019 10:15:57 GMT
  content-disposition: attachment; filename="test.zip"
  content-length: 128
  Content-Type: application/zip
  content-encoding: none
  Connection: Upgrade, Keep-Alive
  X-Powered-By: PHP/7.2.16
  Upgrade: h2,h2c
  Vary: User-Agent
  Keep-Alive: timeout=5
  Server: Apache
  
  UEsDBBQAAAAAADEcwU7q5x4NDgAAAA4AAAAIAAAAdGVzdC50eHR0aGlzIGlzIGEgdGVzdFBLAQIUABQAAAAAADEcwU7q5x4NDgAAAA4AAAAIAAAAAAAAAAEAIAAAAAAAAAB0ZXN0LnR4dFBLBQYAAAAAAQABADYAAAA0AAAAAAA=
  </code></pre>
  
  <p>Both the response payloads are identical and besides a few tiny changes in the response headers.</p>
  
  <p>Such as the letter casing and the cloudflare headers.</p>
  
  <p>I don't see any reason why the zip file should be 0 bytes when trying to save the download prompt through the domain.</p>
  
  <p>When I press ctrl+j to view the download history.
  It looks fine for the direct ip download on the bottom and a weird message for the top domain one.</p>
  
  <p><a href="https://i.stack.imgur.com/06Czb.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/06Czb.png" alt="enter image description here"></a></p>
  
  <p>Does anyone have any suggestions on how to solve this?</p>