Tuesday 11 April 2017

Use express sendFile for HEAD requests

sendFile is for sending files and it also figures out some interesting headers from the file (like content length). For a HEAD request I would ideally want the exact same headers but just skip the body.

There doesn't seem to be an option for this in the API. Maybe I can override something in the response object to stop it from sending anything?

Here's what I got:

res.sendFile(file, { headers: hdrs, lastModified: false, etag: false })

Has anyone solved this?



via Martin Algesten

No comments:

Post a Comment