13

Do most (IE, FF, Safari, Chrome, Opera) make multiple HTTP Requests for a PDF file when displaying the PDF in a browser? I am working on an issue integrating with WebTrends Web Analytics software, and the statistics around PDFs appear to be incorrect. Support told me that because WebTrends parses the Web Servers access logs to determine traffic, downloads, etc. it has a difficult time determining accurate PDF downloads because:
When a user clicks on a PDF and the PDF opens in the user's browser via the Acrobat Reader browser plug-in, each page is downloaded one-at-a-time -- it does this to conserve bandwidth, if a user only views the first 2 pages of a 50 page PDF, only the first 2 pages are downloaded.

This sounds fishy to me (how could a HTTP Request be made to only serve out a portion of a binary file?) -- I've been searching Google, but haven't found anything that speaks to this.

I will try to find some IE software that lets me sniff the HTTP traffic tomorrow to see if i can observe this phenomenon.

Any info/thoughts are appreciated though.

3
  • 1
    Not an answer as such, but http does support downloading parts of files via the content-range header. Perhaps PDF uses it... shrugs
    – Will
    Nov 30, 2009 at 3:52
  • 2
    I've found Fiddler very handy for such IP packet sniffing.
    – Nate C-K
    Nov 30, 2009 at 4:09
  • See RFC 2616, Section 3.12. Nov 30, 2009 at 9:04

4 Answers 4

14

If your site returns an HTTP response header like this:

Accept-Ranges: bytes

the PDF reader will close the intitial connection after reading just a few KB of the document. It then requests sections of the document as required with the Range request header, e.g.:

Range: bytes=242107-244329, 8060-76128

An example of a URL that does this is http://www.ovationguitars.com/img/OVmanual.pdf .

If you don't return the Accept-Ranges header then the PDF document will be downloaded in a single request (e.g. http://manuals.info.apple.com/en/iphone_user_guide.pdf )

You can see the behavior of the PDF reader in IE using HttpWatch.

** Disclaimer: This answer was posted by Simtec Limited, the makers of HttpWatch **

4
  • Very interesting thank you! So it appears this is possible, however after further investigation (watching the HTTPRequests/Respsonses) it does not appear that Adobe Acrobat reader plugin for IE supports creating requests in this fashion (and possibly nor does the Web application that is serving the PDFs, though i havent sent it any synthetic requests the byte ranges)
    – empire29
    Dec 1, 2009 at 14:36
  • I checked the iphone_user_guide.pdf (manuals.info.apple.com/MANUALS/1000/MA1565/en_US/…) in Chrome and I get 2 requests: The first one is ok. The second one is canceled. May 23, 2016 at 11:31
  • I'm still seeing this behaviour today, and Fiddler shows that there are no "accept-ranges" headers involved. Jun 2, 2016 at 18:25
  • Just an FYI - I tried disabling Chrome's PDF viewer and using PDF.js plugin for Chrome (which is what FF uses) - and Chrome still keeps issuing (and then canceling) the second request...
    – zam6ak
    Jul 14, 2016 at 17:41
2

For me as of June 2016, Firefox and IE11 only make one call.

Chrome makes two calls if there is no Content-Disposition header. When it is missing, Chrome does two GETs, seems to cancel the second, and shows the PDF in the browser. The server does not know that the second is cancelled, and sends out the PDF again.

When this header is sent from the server, Chrome only makes one call and launches or saves the file.

Content-Disposition: attachment

(You can also suggest the file name to be used when the user saves the file...)

Content-Disposition: attachment; filename=test.pdf
3
  • 2
    Adding this header does prevent the second call, but it also causes Chrome to download the PDF like an attachment and not immediately open it within the browser.
    – kman
    Jun 4, 2016 at 21:19
  • Yes. I still think it is a bug, but this is one way around it. Jun 5, 2016 at 4:13
  • 2
    Well the problem is the PDF plugin of Chrome. With Content-Disposition: attachment the PDF plugin is not used. This is why there is no error. More details here: bugs.chromium.org/p/chromium/issues/detail?id=587709 Jun 15, 2016 at 15:59
0

My thoughts are that you are spot on: your plug-in can not (and should not) split PDF's into requests.

I have a web application which serves PDF files from a request (a single request) and displays in a plug-in. It displays the entire PDF without getting any more information.

Also, if you are looking for a HTTP sniffer you could try Fiddler. I have found this useful during web site debugging.

1
  • I checked it out in HTTPWatch using IE (the company's official "supported" browser) with the latest Adobe Acrobat reader plugin and it was pulling down entire PDFs. I did not see anything in the headers about byte ranges.
    – empire29
    Dec 1, 2009 at 14:34
0

In my tests, double requests to a PDF occours in Chrome if I have the REST Console 4.0.2 extension enabled. Disabling this extension makes Chrome work as expected (only one request).

Edit: Instapaper extension enabled also makes Chrome do double requests to PDF.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.