Pdf.js: Can't enable progressive rendering (i.e. range-request download)

Created on 19 May 2017  Â·  10Comments  Â·  Source: mozilla/pdf.js

Link to PDF file (or attach file here):
out.pdf

Configuration:

  • Web browser and its version: Google Chrome 58.0.3029.110 (64-bit)
  • Operating system and its version: Debian GNU/Linux 9.0 (stretch)
  • PDF.js version: 1.8.188
  • Is an extension: no

PDFJS doesn't initiate range request, just downloads the whole file, however, server have range request support:

curl -s -H "Range: bytes=500-1000" -D  - http://localhost:3000/api/files/7/preview/file.pdf -o /dev/null
HTTP/1.1 206 Partial Content
Connection: keep-alive
Set-Cookie: csrf-token=yaP9VNyKqYQ5Cs903x45WpiVhYvD8lbUX%2FtIQeG8ZrV1L%2Fq6LdI7ApKn7LFW9a%2F%2BuzGrmQSU3o8rB6c0;Path=/
Set-Cookie: ring-session=9PbMnYqfDK7frq%2BKLMjC3AOMGURDSm%2BNHhQy8voCTsdk4692%2FDJDhxm5oBm89prB%2FnSTVOnqSTItdC176rzdm%2BVNd2Ck3YX2xk9Bbi5%2FtJiPjGRzHk6ifsNfIwR5Nyi4ZnVhCa03tD%2FsUo6dVBjWlffiIGsS2x%2F836IXTMGM90mrz5PtRZLQIeaIED91Ehd64ip0MWhlAWBuFMDy4%2BVeog%3D%3D--pfr0sATxg5WkppYe2MKp4ih%2BUMNoXkMQIRPhRf6aUzk%3D;Path=/;HttpOnly;Max-Age=31536000
Content-Range: bytes 500-1000/2568004
Server: undertow
Content-Length: 501
Date: Fri, 19 May 2017 05:01:08 GMT

But in network console I see:

out.pdf 200 xhr Other   2.4 MB

I've done linearization with qpdf --linearize

All 10 comments

I also can't see any range requests at pdfjs demo page

WFM, please provide a link to public server to reproduce the issue

screen shot 2017-05-19 at 7 57 56 am

Closing as duplicate of #8422

Sorry, just was too lazy to deploy server somewhere to public.
After analyzing pdf.worker.js I've find out this:

if (fullRequestXhr.getResponseHeader('Accept-Ranges') !== 'bytes') {
      return false;
}

So, after I've add Accept-Ranges: bytes I've finally started to get 206

So, after I've add Accept-Ranges: bytes I've finally started to get 206

If you are implementing range support from scratch (e.g. in server script) instead of using web server's, please see https://tools.ietf.org/html/rfc7233

hi zarkone, where did you added Accept-ranges: bytes in my case im receiving none, i already enabled header in ubuntu server but still receiving none as the response.. the range request working perfectly in my local server not in live one

hey @vickyatjoy, unfortunately not sure what is the reason in your case. It depends on your setup and could be something like apachenginx proxy cuts the headers. But in my case NGINX proxy doesn't cut anything by default.

Take a look at what headers it sendsreturns on your local server. In my case it was (taken from chrome netwrok console):

[General]
Request URL:http://localhost:3000/api/files/428/preview/428.pdf
Request Method:GET
Status Code:206 Partial Content
Remote Address:[::1]:3000
Referrer Policy:no-referrer-when-downgrade

[Response Headers]
Accept-Ranges:bytes
Connection:keep-alive
Content-Length:65536
Content-Range:bytes 0-65535/498782
Date:Fri, 23 Mar 2018 07:43:46 GMT
Server:undertow
Set-Cookie:[ ... ]

[Request Headers]
Accept:*/*
Accept-Encoding:gzip, deflate, br
Accept-Language:ru-RU,ru;q=0.9,en-US;q=0.8,en;q=0.7,da;q=0.6
Connection:keep-alive
Cookie: [ ... ]
Host:localhost:3000
Range:bytes=0-65535
Referer:http://localhost:3000/target/pdf.worker.min.js
User-Agent:Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.167 Safari/537.36

Also, is it possible that you forgot to set Content-Range or Content-Length properly?

Thanks for the hint Zarkone, in my case it was my internet connection insecure, our NSA team configured my ip in two different policy groups with two different ip's, now it's been resolved

Great!

Yes, proxy is usually tough topic -- glad that you've managed to debug it
relatively quick.

On Fri, Mar 23, 2018, 7:54 PM Vignesh Rajendran notifications@github.com
wrote:

Thanks for the hint Zarkone, in my case it was my internet connection
insecure, our NSA team configured my ip in two different policy groups with
two different ip's, now it's been resolved

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/mozilla/pdf.js/issues/8425#issuecomment-375655816,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABz8hgZbFGFGgHqp2RJwLZpjjRrwHg_3ks5thPCAgaJpZM4NgFXg
.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

THausherr picture THausherr  Â·  3Comments

jigskpatel picture jigskpatel  Â·  3Comments

sujit-baniya picture sujit-baniya  Â·  3Comments

hp011235 picture hp011235  Â·  4Comments

timvandermeij picture timvandermeij  Â·  4Comments