@@ -8636,7 +8636,7 @@ inline bool ClientImpl::redirect(Request &req, Response &res, Error &error) {
86368636 if (location.empty ()) { return false ; }
86378637
86388638 thread_local const std::regex re (
8639- R"( (?:(https?):)?(?://(?:\[([a-fA-F\d:]+)\]|([^:/?#]+))(?::(\d+))?)?([^?#]*)(\? [^#]*)?(?:#.*)?)" );
8639+ R"( (?:(https?):)?(?://(?:\[([a-fA-F\d:]+)\]|([^:/?#]+))(?::(\d+))?)?([^?#]*)(?:\?( [^#]*) )?(?:#.*)?)" );
86408640
86418641 std::smatch m;
86428642 if (!std::regex_match (location, m, re)) { return false ; }
@@ -8661,18 +8661,16 @@ inline bool ClientImpl::redirect(Request &req, Response &res, Error &error) {
86618661 if (next_host.empty ()) { next_host = host_; }
86628662 if (next_path.empty ()) { next_path = " /" ; }
86638663
8664- auto path = next_path + next_query;
8664+ if (!next_query. empty ()) { detail::parse_query_text ( next_query, req. params ); }
86658665
86668666 // Same host redirect - use current client
86678667 if (next_scheme == scheme && next_host == host_ && next_port == port_) {
8668- this ->set_path_encode (
8669- false ); // Disable path encoding, redirects should already be encoded
8670- return detail::redirect (*this , req, res, path, location, error);
8668+ return detail::redirect (*this , req, res, next_path, location, error);
86718669 }
86728670
86738671 // Cross-host/scheme redirect - create new client with robust setup
86748672 return create_redirect_client (next_scheme, next_host, next_port, req, res,
8675- path , location, error);
8673+ next_path , location, error);
86768674}
86778675
86788676// New method for robust redirect client creation
@@ -8758,8 +8756,7 @@ inline void ClientImpl::setup_redirect_client(ClientType &client) {
87588756 client.set_keep_alive (keep_alive_);
87598757 client.set_follow_location (
87608758 true ); // Enable redirects to handle multi-step redirects
8761- client.set_path_encode (
8762- false ); // Disable encoding, redirects should already be encoded
8759+ client.set_path_encode (path_encode_);
87638760 client.set_compress (compress_);
87648761 client.set_decompress (decompress_);
87658762
0 commit comments