rhardih / serve

Simple http server for localhost development with flags for enabling gzip and http2
MIT License
102 stars 11 forks source link

Ability to send custom HTTP headers? #6

Closed simonwiles closed 2 years ago

simonwiles commented 2 years ago

This little server is so useful, thanks! I've not found anything else that's quite so handy.

It would be great to have the ability to specify custom HTTP headers. For my immediate use case I want to be able to set:

Cross-Origin-Embedder-Policy: require-corp
Cross-Origin-Opener-Policy: same-origin

so as to be able to use the performance.measureUserAgentSpecificMemory API while developing, but I'm sure there will be lots of other use cases.

simonwiles commented 2 years ago

I just found myself wishing for this functionality again, and arrived at this issue having completely forgotten that I opened it myself < 6 months ago... 😳

If I implemented this would you be interested in a PR?

rhardih commented 2 years ago

If it doesn't complicate the current usability, it would be a welcome addition. 👍

simonwiles commented 2 years ago

I have something that implements the curl api for headers -- basically just -H/--header that you can repeat as often as necessary, e.g.

serve --H "X-Clacks-Overhead: GNU Terry Pratchett" ...

I'll prepare a PR and raise it for your consideration. Thanks!

rhardih commented 2 years ago

Thank you, merged! :)