mirror of
https://github.com/yhirose/cpp-httplib.git
synced 2026-12-05 22:18:27 +00:00
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:
1 parent
c438858d92
commit
5fd66e46df
2 files changed
+55
-4
No files matched your search
@@ -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_) {
|
||||
|
||||
Reference in new issue
Block a user