1
0
mirror of synced 2025-12-18 16:34:09 +03:00

Avoid unncessary copying of request and response objects (#2310)

This commit is contained in:
Aaron Gokaslan
2025-12-17 12:04:17 -05:00
committed by GitHub
parent 51b704b902
commit 0461cb770c

View File

@@ -6157,8 +6157,8 @@ inline bool redirect(T &cli, Request &req, Response &res,
auto ret = cli.send(new_req, new_res, error); auto ret = cli.send(new_req, new_res, error);
if (ret) { if (ret) {
req = new_req; req = std::move(new_req);
res = new_res; res = std::move(new_res);
if (res.location.empty()) { res.location = location; } if (res.location.empty()) { res.location = location; }
} }
@@ -10554,7 +10554,7 @@ inline bool ClientImpl::handle_request(Stream &strm, Request &req,
auto req2 = req; auto req2 = req;
req2.path = "http://" + host_and_port_ + req.path; req2.path = "http://" + host_and_port_ + req.path;
ret = process_request(strm, req2, res, close_connection, error); ret = process_request(strm, req2, res, close_connection, error);
req = req2; req = std::move(req2);
req.path = req_save.path; req.path = req_save.path;
} else { } else {
ret = process_request(strm, req, res, close_connection, error); ret = process_request(strm, req, res, close_connection, error);
@@ -10606,7 +10606,7 @@ inline bool ClientImpl::handle_request(Stream &strm, Request &req,
Response new_res; Response new_res;
ret = send(new_req, new_res, error); ret = send(new_req, new_res, error);
if (ret) { res = new_res; } if (ret) { res = std::move(new_res); }
} }
} }
} }