SuaveIO / suave

Suave is a simple web development F# library providing a lightweight web server and a set of combinators to manipulate route flow and task composition.
https://suave.io
Other
1.32k stars 198 forks source link

Customize HTTP Server Header Value #755

Closed enkomio closed 3 years ago

enkomio commented 3 years ago

I need to customize my server response, and in particular the server name. I see that the HTTP Server header value is set to a read only string and it is not possible to change it. Is this due to a specific reason?

What about removing the server header name from https://github.com/SuaveIO/suave/blob/master/src/Suave/HttpOutput.fs#L137?

ademar commented 3 years ago

You can disable the server header in the configuration record.

https://github.com/SuaveIO/suave/blob/master/src/Suave/Web.fs#L92

enkomio commented 3 years ago

Yeah I know, but in my project I need to send as Server header a different string. For example, instead of sending the header:

Server: Suave (https://suave.io)

I'd like to send:

Server: My custom value

If I set hideHeader = true and use addHeader "Server" "My custom value", the Server header is not set due to the exclusions list pointed in my previous comment. So, I was wondering if the server string can be removed from the exclusions list in the writeResponse function or provide a mechanism to customize this list.

ademar commented 3 years ago

Ok, I've pushed a fix that allows you to set a custom Server header; you still need to set hideHeader = true otherwise Suave will output the default Server string.

I'll release a new nuget later today or tomorrow.

enkomio commented 3 years ago

Awesome, thanks!