How to disable the range option in http request header?

☆樱花仙子☆ 提交于 2021-02-07 03:22:53

问题


While downloading a PDF via google chrome, i receive a 206 status response from the server. After going through the RFC, i found out that the client is making a conditional GET request appending a range header. is there any way to disable the range header while making the request or using a different browser is a solution?


回答1:


What server are you using?

This is the apache documentation for mod_headers. You can set the Accept-Ranges header to none

http://httpd.apache.org/docs/2.2/mod/mod_headers.html

Try setting "Accept-Ranges none" in the httpd.conf file.

The mod_headers module must be loaded in the server too.

Also, when the request of a pdf or often streamed file it's done through chrome or an adobe plugin or so (other plugins), they will always attempt to do the GET request with Range:0- and try partial requests of the file to show content to the user (first pages of the pdf if the pdf is big) and manage the download so the server will respond with 206 status.




回答2:


Just make sure you have mod_headers enabled, then add this to your Apache config:

<Files *.pdf>
    Header set Accept-Ranges none 
</Files>

The issue you're experiencing is a documented bug in Chrome: when a user tries to save a PDF file before the whole file has had a chance to download, the resulting file is corrupted. This fix stops Chrome from making partial requests for the file.



来源:https://stackoverflow.com/questions/20894640/how-to-disable-the-range-option-in-http-request-header

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!