-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add .headers
support
#360
Comments
I'd love to see this merged into http-server. It's harder than I expected to find a simple Node HTTP server that lets me set custom headers easily. |
I am sorry, I cannot understand how to use it. I added a |
@LvChengbin it's not implemented yet, but there seems to be enough interest in it to do the work now. @nbarbettini thanks for the +1. I'd been a bit concerned that this changed the nature of http-server a bit, but given that these are optional files that augment requests, I think it's fine--though I'll still probably put it behind an optional command line flag to avoid the double-disk checking for each request if it's not in use. |
Netlify uses a top-level Having the header files closer to the actual requested file seems better, but a single top-level file does avoid the double-file disk reads per each request (so that's a good). |
Out of desperation I've forked all this and merged hedefalk's 7 year old version with the latest stuff here. It's a temporary hack solution and I'm likely not going to merge future changes into that, so it's officially unmaintained, but it's a workaround for the desperate like me until the authors merge in hedefalk's changes. |
The
.headers
file idea comes from the File Handler in wptserve (a Python-based server for running the Web Platform Tests system at the W3C).They look like this:
In
wptserve
they can be associated with single files (index.html.headers
orindex.headers
) as well as directories (for/about/
style requests) via a__dir__.headers
file (because Python-esque).The advantage is that you can then provide any number of HTTP headers for any file or "directory" or perhaps even non-resource requests such as handling HEAD-only requests or
303 See Also
specific entities.This could be used to address a number of issues related mentioned here related to caching and content-types as well as things like advanced CORS and CSP handling.
Thoughts welcome!
The text was updated successfully, but these errors were encountered: