dotnet / WatsonWebserver

Watson is the fastest, easiest way to build scalable RESTful web servers and services in C#.
MIT License
411 stars 84 forks source link

Fix invalid host header when creating multiple webserver instances #148

Closed bemon closed 5 months ago

bemon commented 5 months ago

Hi,

I found a bug in webserver code. When creating multiple instances of webserver in same process ( eg. same host, different port), WebserverConstants.HeaderHost is overriden. Originally it has "Host" value, but in Webserver constructor is then overriden by host:port value from settings.

It results in invalid value for DefaultHeaders in next instance of Webserver and throws when handling routes, because HeaderHost is used as a key for default headers at first init. Its a bug, but if its intended - i think its bad practice to use global vars in that way.

This pull request simply sets default header host at webserver constructor manually.

bemon commented 5 months ago

@dotnet-policy-service agree

jchristn commented 5 months ago

@bemon thank you so much for catching this, merging now!