From 4106c92fc6e434b4e905ff4e9f01d251804862f9 Mon Sep 17 00:00:00 2001 From: Liu Qing Date: Sat, 7 Oct 2023 15:40:52 +0800 Subject: [PATCH] set redirect before send http request If the http response got back before set redirect task, then segment fault will see. This patch fix it by switch the order of the two. Signed-off-by: Liu Qing --- Release/src/http/client/http_client_asio.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Release/src/http/client/http_client_asio.cpp b/Release/src/http/client/http_client_asio.cpp index 07bb4885bf..1f95ae007b 100644 --- a/Release/src/http/client/http_client_asio.cpp +++ b/Release/src/http/client/http_client_asio.cpp @@ -2149,12 +2149,13 @@ pplx::task asio_client::propagate(http_request request) // Use a task to externally signal the final result and completion of the task. auto result_task = pplx::create_task(context->m_request_completion); + if (client_config().max_redirects() > 0) + result_task = result_task.then(http_redirect_follower(client_config(), request)); + // Asynchronously send the response with the HTTP client implementation. this->async_send_request(context); - return client_config().max_redirects() > 0 - ? result_task.then(http_redirect_follower(client_config(), request)) - : result_task; + return result_task; } } // namespace details } // namespace client