erlyaws / yaws

Yaws webserver
https://erlyaws.github.io
BSD 3-Clause "New" or "Revised" License
1.28k stars 267 forks source link

xsendfile like feature #351

Closed leoliu closed 5 years ago

leoliu commented 5 years ago

I have been wondering about a (hidden) feature for a few months.

Yaws can serve static files with support for conditional and range requests. However such feature is not easily available to a user-supplied appmod. I have seen a few scenarios where a appmod needs to process the request - authentication, DB lookup etc. - then deliver a private static file if conditions are met. i.e. I was wishing for something like this: out/1 returns {sendfile, PathToFile} or {sendfile, Headers, PathToFile} and Yaws figures out the best way to deliver it to the clients with proper handling of conditional and range requests.

Such feature is not unlike the xsendfile feature provided by reverse proxies such as nginx, apache, h2o etc.

vinoski commented 5 years ago

Have you tried {page, Path}?

leoliu commented 5 years ago

@vinoski,

I was looking at {page, ...} before opening this bug but somehow I dismissed it before even trying it out. I have just done that and it seems to be the solution I was looking for. Thanks for the pointer. Closing for now.

Leo