From 1e15054e0eb9d2a4bd72915fd15ac71f9c2710ad Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Sat, 5 Dec 2009 22:10:44 +0000 Subject: [PATCH] treat redirect locations slightly more graceful --- src/http_connection.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/http_connection.cpp b/src/http_connection.cpp index 7c829f835..5d10c37bc 100644 --- a/src/http_connection.cpp +++ b/src/http_connection.cpp @@ -622,14 +622,11 @@ void http_connection::on_read(error_code const& e std::string url = m_url; // remove the leaf filename std::size_t i = url.find_last_of('/'); - if (i == std::string::npos) - { + if (i != std::string::npos) + url.resize(i); + if ((url.empty() || url[url.size()-1] != '/') + && (location.empty() || location[0] != '/')) url += '/'; - } - else - { - url.resize(i + 1); - } url += location; get(url, m_timeout, m_priority, &m_proxy, m_redirects - 1);