Mobile app version of vmapp.org
Login or Join
Shanna517

: HTTP Header broken? Browsers don't open our pdf, but open all other pdfs My Firefox and Chrome usually open PDF files very nicely, without asking and within the browser window. When clicking

@Shanna517

Posted in: #Django #HttpHeaders #Lighttpd #Pdf

My Firefox and Chrome usually open PDF files very nicely, without asking and within the browser window.

When clicking on a link to a PDF on our own website:


Firefox asks if it should download them, to see it I need to open the download history.
Chrome downloads it automatically, but here as well, opening the PDF needs an extra click.


If I copy the PDF to a different Server (Django installation with lighttpd), Firefox and Chrome will display it nicely as usual.

What's wrong?

10.02% popularity Vote Up Vote Down


Login to follow query

More posts by @Shanna517

2 Comments

Sorted by latest first Latest Oldest Best

 

@Sims2060225

The solution was rather special.

The server had the default mime-type application/octet-stream for PDF files. After changing this to application/pdf everything worked fine.

In the lighttpd configuration I achieved the change by adding this definition:

mimetype.assign += ( ".pdf" => "application/pdf" )

10% popularity Vote Up Vote Down


 

@Heady270

See How to force files to open in browser instead of download (pdf)? which has an answer from ColinM that tells you exactly what the headers should be:


To indicate to the browser that the file should be viewed in the browser:

Content-Type: application/pdf
Content-Disposition: inline; filename="filename.pdf"


To have the file downloaded rather than viewed:

Content-Type: application/pdf
Content-Disposition: attachment; filename="filename.pdf"


EDIT: The quotes around the filename are required if the filename contains special characters such as filename[1].pdf which may otherwise break the browser's ability to handle the response.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme