| 3653 | |
| 3654 | template <typename T> |
| 3655 | inline bool redirect(T &cli, Request &req, Response &res, |
| 3656 | const std::string &path, const std::string &location, |
| 3657 | Error &error) { |
| 3658 | Request new_req = req; |
| 3659 | new_req.path = path; |
| 3660 | new_req.redirect_count_ -= 1; |
| 3661 | |
| 3662 | if (res.status == 303 && (req.method != "GET" && req.method != "HEAD")) { |
| 3663 | new_req.method = "GET"; |
| 3664 | new_req.body.clear(); |
| 3665 | new_req.headers.clear(); |
| 3666 | } |
| 3667 | |
| 3668 | Response new_res; |
| 3669 | |
| 3670 | auto ret = cli.send(new_req, new_res, error); |
| 3671 | if (ret) { |
| 3672 | req = new_req; |
| 3673 | res = new_res; |
| 3674 | res.location = location; |
| 3675 | } |
| 3676 | return ret; |
| 3677 | } |
| 3678 | |
| 3679 | inline std::string params_to_query_str(const Params ¶ms) { |
| 3680 | std::string query; |
no test coverage detected