Compare the redirect host case-insensitively (#2708)

* Compare the redirect host case-insensitively

* Test a Unix socket redirect to LOCALHOST

---------

Co-authored-by: yhirose <yuji.hirose.bug@gmail.com>
This commit is contained in:
Leng Niuandyhirose authored and GitHub committed 2026-12-04 22:04:17 -05:00
1 parent c438858d92
commit 5fd66e46df
2 files changed
+55 -4

No files matched your search

+6 -4
View File
@@ -17787,10 +17787,12 @@ inline bool ClientImpl::redirect(Request &req, Response &res, Error &error) {
auto path = std::move(next_path) + next_query;
// A Unix socket client sends "Host: localhost", so a Location naming
// localhost names this client too.
auto is_same_host = next_host == host_ ||
(address_family_ == AF_UNIX && next_host == "localhost");
// Host names are case-insensitive (RFC 3986 3.2.2). A Unix socket client
// sends "Host: localhost", so a Location naming localhost names this client
// too.
auto is_same_host = detail::case_ignore::equal(next_host, host_) ||
(address_family_ == AF_UNIX &&
detail::case_ignore::equal(next_host, "localhost"));
// Same host redirect - use current client
if (next_scheme == scheme && is_same_host && next_port == port_) {