pub fn find_site<'a>(
config: &'a Config,
host: &str,
is_tls: bool,
) -> Option<&'a SiteConfig>Expand description
Find a site configuration matching the given Host header value.
Browsers on default ports omit the port from the Host header:
- HTTPS on 443 →
Host: example.com(no:443) - HTTP on 80 →
Host: example.com(no:80)
But config keys include the port: "example.com:443", "example.com:80".
Look up a site by Host header value.
Tries, in order:
- Exact match on the raw host string.
- If host has no port → append default port (443 for TLS, 80 for HTTP) and retry.
- For TLS, match by SNI hostname if exactly one site matches.
- If host has a port → strip it and try the bare hostname.
§Limitations
For non-default TLS ports (e.g., 8443), browsers include the port in Host
(Host: example.com:8443), so exact match works. A client sending Host: example.com
without a port to a TLS listener on :8443 gets 404 — that violates normal HTTP usage.