mirror of
https://github.com/yhirose/cpp-httplib.git
synced 2025-05-15 09:18:27 +00:00
Support remote_addr and remote_port REMOTE_PORT header in client Request (#433)
This commit is contained in:
parent
df138366e4
commit
d0b123be26
2 changed files with 59 additions and 37 deletions
|
@ -801,6 +801,9 @@ protected:
|
|||
.Get("/remote_addr",
|
||||
[&](const Request &req, Response &res) {
|
||||
auto remote_addr = req.headers.find("REMOTE_ADDR")->second;
|
||||
EXPECT_TRUE(req.has_header("REMOTE_PORT"));
|
||||
EXPECT_EQ(req.remote_addr, req.get_header_value("REMOTE_ADDR"));
|
||||
EXPECT_EQ(req.remote_port, std::stoi(req.get_header_value("REMOTE_PORT")));
|
||||
res.set_content(remote_addr.c_str(), "text/plain");
|
||||
})
|
||||
.Get("/endwith%",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue