azadkuh / qhttp

a light-weight and asynchronous HTTP library (both server & client) in Qt5 and c++14
MIT License
484 stars 158 forks source link

Fix Host header always containing port 65535 when URI does not contain explicit port #36

Closed phoerious closed 4 years ago

phoerious commented 7 years ago

The port number inside the Host header is always USHRT_MAX (i.e., 65535) when no explicit port was set in the URL. This causes many webservers to return the wrong website (or a 404 response therefore) when they manage multiple name-based virtual hosts.

This patch handles URLs without explicit port correctly and does not add any explicit port number to the Host header when the URL also contains none. I chose not to set any explicit port in that case, because an explicit port 80 (or 443) can also cause trouble with virtual hosts.