5

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?

3 Answers 3

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.

Sign up to request clarification or add additional context in comments.

31 Comments

I am not sure of the server that I am accessing. But I thought it was more of a client side issue. Anyways thanks for the response on the apache. And issue that i mentioned worked for one client machine and failed for the other.
So do we need to add the statement "Accept-Ranges: none" in the httpd.conf file of the Server?
Is the pdf file large? When files are large or connection is bad, servers throw a 206 status. Normally browsers get the 206 and manage the download in parts for you. Have you tried with another browser just in case?
If the "Accept-Ranges" feature on the server is active, files can be downloaded in parts (normally active if the server offers big files)
Yes, set "Accept-Ranges: none" in the httpd.conf file.
|
1

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.

Comments

0

This a solution for IIS. Verified for IIS 10.0

There is no built-in mechanism to achieve that but you can use "URL Rewrite" (https://www.iis.net/downloads/microsoft/url-rewrite) for that.

  1. Create a new Outbound Rule
  2. Apply a Name like Disable accept-ranges header
  3. Match region:
    Set Mathing scope to Server Variable
  4. Match region:
    Set Variable name to RESPONSE_ACCEPT_RANGES.
    I did not find a documentation on available variables. You can add/modify any http header by using the format RESPONSE_MyHttpHeader
  5. Match region:
    Set Variable value to Matches the Pattern
    Set Set Using to Regular Expressions
    Set Pattern to ".*" (without the quotes)
    Set (check) Ignore case
  6. Action:
    Set Action Type to Rewrite
    Set the Value to none
    Set (check) Replace existing server variable value

You can test your changes using curl:

curl -I https://<AddServerUrlHere>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.