web seed fix

This commit is contained in:
Arvid Norberg 2010-02-20 16:53:38 +00:00
parent 47f3a18d65
commit b362795f9d
3 changed files with 15 additions and 10 deletions

View File

@ -144,7 +144,10 @@ namespace libtorrent
std::string m_host;
int m_port;
std::string m_path;
std::string m_url;
// this is const since it's used as a key in the web seed list in the torrent
// if it's changed referencing back into that list will fail
const std::string m_url;
// the first request will contain a little bit more data
// than subsequent ones, things that aren't critical are left

View File

@ -99,7 +99,7 @@ namespace libtorrent
void on_receive(error_code const& error
, std::size_t bytes_transferred);
std::string const& url() const { return m_url; }
std::string const& url() const { return m_original_url; }
virtual void get_specific_peer_info(peer_info& p) const;
virtual bool in_handshake() const;
@ -146,6 +146,7 @@ namespace libtorrent
int m_port;
std::string m_path;
std::string m_url;
std::string m_original_url;
// the first request will contain a little bit more data
// than subsequent ones, things that aren't critical are left

View File

@ -65,6 +65,7 @@ namespace libtorrent
, policy::peer* peerinfo)
: peer_connection(ses, t, s, remote, peerinfo)
, m_url(url)
, m_original_url(url)
, m_first_request(true)
, m_range_pos(0)
, m_block_pos(0)
@ -120,7 +121,7 @@ namespace libtorrent
web_peer_connection::~web_peer_connection()
{
boost::shared_ptr<torrent> t = associated_torrent().lock();
if (t) t->disconnect_web_seed(m_url, web_seed_entry::url_seed);
if (t) t->disconnect_web_seed(m_original_url, web_seed_entry::url_seed);
}
boost::optional<piece_block_progress>
@ -422,9 +423,9 @@ namespace libtorrent
{
std::string retry_after = m_parser.header("retry-after");
// temporarily unavailable, retry later
t->retry_web_seed(m_url, web_seed_entry::url_seed, atoi(retry_after.c_str()));
t->retry_web_seed(m_original_url, web_seed_entry::url_seed, atoi(retry_after.c_str()));
}
t->remove_web_seed(m_url, web_seed_entry::url_seed);
t->remove_web_seed(m_original_url, web_seed_entry::url_seed);
std::string error_msg = to_string(m_parser.status_code()).elems
+ (" " + m_parser.message());
if (m_ses.m_alerts.should_post<url_seed_alert>())
@ -446,7 +447,7 @@ namespace libtorrent
if (location.empty())
{
// we should not try this server again.
t->remove_web_seed(m_url, web_seed_entry::url_seed);
t->remove_web_seed(m_original_url, web_seed_entry::url_seed);
disconnect(errors::missing_location, 2);
return;
}
@ -471,14 +472,14 @@ namespace libtorrent
size_t i = location.rfind(path);
if (i == std::string::npos)
{
t->remove_web_seed(m_url, web_seed_entry::url_seed);
t->remove_web_seed(m_original_url, web_seed_entry::url_seed);
disconnect(errors::invalid_redirection, 2);
return;
}
location.resize(i);
}
t->add_web_seed(location, web_seed_entry::url_seed);
t->remove_web_seed(m_url, web_seed_entry::url_seed);
t->remove_web_seed(m_original_url, web_seed_entry::url_seed);
disconnect(errors::redirecting, 2);
return;
}
@ -512,7 +513,7 @@ namespace libtorrent
{
m_statistics.received_bytes(0, bytes_transferred);
// we should not try this server again.
t->remove_web_seed(m_url, web_seed_entry::url_seed);
t->remove_web_seed(m_original_url, web_seed_entry::url_seed);
disconnect(errors::invalid_range);
return;
}
@ -527,7 +528,7 @@ namespace libtorrent
{
m_statistics.received_bytes(0, bytes_transferred);
// we should not try this server again.
t->remove_web_seed(m_url, web_seed_entry::url_seed);
t->remove_web_seed(m_original_url, web_seed_entry::url_seed);
disconnect(errors::no_content_length, 2);
return;
}