svenstaro/miniserve

Question about the custom headers' priority?

Closed this issue · 4 comments

In a word: custom headers set with --header switch will be overwritten in miniserve's inner. I think it should be a higher priority than the value which miniserve generated.

Here my scenes:

Serving a PDF file, another guy opens it in the browser, but browser starts downloading it because of the header content-disposition: attachment; filename="CSAPP.pdf". So I try to set this header using --header content-disposition:inline argument, but this value seems be overwritten. In Chrome's F12, I see the header was not changed. If I set another header like --header foo-bar:hello, it's fine.

Now I just want to change this header and enable others to preview PDF file in browser. How should I do? Is there another method to make this?

The custom header function's PR here, thanks also.

Now I just include pdf.js's viewer, it works fine.

@kkocdko hi, I checked pdf.js for a while but didn't figure out how to combine it with miniserve, what's your workflow?

@GopherJ Sure I can show you an example here but it may be a little complicated. The main idea about it is extract pdf.js, serve the whole dir includes both pdfjs and your pdf file by miniserve then access pdf file by link such as http://127.0.0.1:9005/pdfjs/web/viewer.html?file=/books/cnatda.pdf

@GopherJ And sometimes I found that pdf.js has better experience compare to Chrome's built-in PDF viewer.