From 2ec1c81cd393d796a01c7e7b22cc079165c6694a Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Tue, 2 Mar 2010 21:55:34 +0000 Subject: [PATCH] fixed issue where an http proxy would not be used on redirects --- ChangeLog | 1 + src/http_connection.cpp | 20 ++++++++++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 36a3f8df3..d03954699 100644 --- a/ChangeLog +++ b/ChangeLog @@ -111,6 +111,7 @@ * added support for torrents with odd piece sizes * fixed issue with disk read cache not being cleared when removing torrents * made the DHT socket bind to the same interface as the session + * fixed issue where an http proxy would not be used on redirects release 0.14.9 diff --git a/src/http_connection.cpp b/src/http_connection.cpp index 2f3cccaa5..132f0c5c4 100644 --- a/src/http_connection.cpp +++ b/src/http_connection.cpp @@ -117,7 +117,6 @@ void http_connection::get(std::string const& url, time_duration timeout, int pri ps->username + ":" + ps->password).c_str()); hostname = ps->hostname; port = ps->port; - ps = 0; } else { @@ -220,6 +219,17 @@ void http_connection::start(std::string const& hostname, std::string const& port } #endif + // in this case, the upper layer is assumed to have taken + // care of the proxying already. Don't instantiate the socket + // with this proxy + if ((ps->type == proxy_settings::http + || ps->type == proxy_settings::http_pw) + && !ssl) + { + ps = 0; + } + proxy_settings null_proxy; + #ifdef TORRENT_USE_OPENSSL if (m_ssl) { @@ -236,7 +246,8 @@ void http_connection::start(std::string const& hostname, std::string const& port else #endif { - ret = instantiate_connection(m_resolver.get_io_service(), m_proxy, s->next_layer()); + ret = instantiate_connection(m_resolver.get_io_service() + , ps ? *ps : null_proxy, s->next_layer()); } TORRENT_ASSERT(ret); @@ -257,12 +268,13 @@ void http_connection::start(std::string const& hostname, std::string const& port #endif { ret = instantiate_connection(m_resolver.get_io_service() - , m_proxy, *m_sock.get()); + , ps ? *ps : null_proxy, *m_sock.get()); } TORRENT_ASSERT(ret); } #else - bool ret = instantiate_connection(m_resolver.get_io_service(), m_proxy, m_sock); + bool ret = instantiate_connection(m_resolver.get_io_service() + , ps ? *ps : null_proxy, m_sock); TORRENT_ASSERT(ret); #endif if (m_bind_addr != address_v4::any())