Skip to content
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

Customize HTTP Server Header Value #755

Closed
enkomio opened this issue May 13, 2021 · 4 comments
Closed

Customize HTTP Server Header Value #755

enkomio opened this issue May 13, 2021 · 4 comments
Labels

Comments

@enkomio
Copy link

enkomio commented May 13, 2021

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
Copy link
Member

ademar commented May 14, 2021

You can disable the server header in the configuration record.

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

@enkomio
Copy link
Author

enkomio commented May 14, 2021

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
Copy link
Member

ademar commented May 14, 2021

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
Copy link
Author

enkomio commented May 14, 2021

Awesome, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants