<p dir="auto">When serving a pdf in Chrome using the <code class="notranslate">BinaryFileResponse</code> the response hangs (shows as cancelled in network dev tools with a second one started).</p>
<p dir="auto">I have tracked it down to the <code class="notranslate">Accept-Ranges</code> header that <code class="notranslate">BinaryFileResponse</code> sets:</p>
<p dir="auto"><a href="https://github.com/symfony/symfony/blob/master/src/Symfony/Component/HttpFoundation/BinaryFileResponse.php#L158">https://github.com/symfony/symfony/blob/master/src/Symfony/Component/HttpFoundation/BinaryFileResponse.php#L158</a></p>
<p dir="auto">When I comment out that line it works as expected.</p>
<p dir="auto">Another solution I found was to add <code class="notranslate">Header unset Accept-Ranges</code> to my <code class="notranslate">.htaccess</code></p>
<p dir="auto">I believe this SO question is related: <a href="http://stackoverflow.com/questions/1817750/do-most-browsers-make-multiple-http-requests-when-displaying-a-pdf-from-within-t" rel="nofollow">http://stackoverflow.com/questions/1817750/do-most-browsers-make-multiple-http-requests-when-displaying-a-pdf-from-within-t</a></p>
<p dir="auto">Any thoughts on this?</p>
<p dir="auto">In the binary file response, in the case of a Range headers,</p>
<p dir="auto">this line seems to be forgotten ;<br>
$this-&gt;headers-&gt;set('Content-Length', $end - $start + 1);</p>
<p dir="auto">Otherwise, and ajax request with Chrome or Safari will faill. FF is not impacted</p>