mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-08-05 17:52:29 +00:00
Add http done/failed slots before starting request.
This commit is contained in:
@@ -107,10 +107,10 @@ DownloadFactory::receive_load() {
|
|||||||
// Http handling here.
|
// Http handling here.
|
||||||
m_stream.reset(new std::stringstream);
|
m_stream.reset(new std::stringstream);
|
||||||
|
|
||||||
HttpQueue::iterator itr = m_manager->http_queue()->insert(m_uri, m_stream);
|
m_manager->http_queue()->insert(m_uri, m_stream,
|
||||||
|
[this]() { receive_loaded(); },
|
||||||
itr->add_done_slot(torrent::this_thread::thread(), [this]() { receive_loaded(); });
|
[this](const std::string& error) { receive_failed(error); }
|
||||||
itr->add_failed_slot(torrent::this_thread::thread(), [this](const std::string& error) { receive_failed(error); });
|
);
|
||||||
|
|
||||||
m_variables["tied_to_file"] = (int64_t)false;
|
m_variables["tied_to_file"] = (int64_t)false;
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,8 @@
|
|||||||
namespace core {
|
namespace core {
|
||||||
|
|
||||||
HttpQueue::iterator
|
HttpQueue::iterator
|
||||||
HttpQueue::insert(const std::string& url, std::shared_ptr<std::ostream> stream) {
|
HttpQueue::insert(const std::string& url, std::shared_ptr<std::ostream> stream,
|
||||||
|
std::function<void()> done_fn, std::function<void(const std::string&)> failed_fn) {
|
||||||
auto itr = base_type::insert(end(), torrent::net::HttpGet(url, stream));
|
auto itr = base_type::insert(end(), torrent::net::HttpGet(url, stream));
|
||||||
|
|
||||||
itr->set_max_file_size(15 << 20);
|
itr->set_max_file_size(15 << 20);
|
||||||
@@ -18,9 +19,12 @@ HttpQueue::insert(const std::string& url, std::shared_ptr<std::ostream> stream)
|
|||||||
for (auto& slot : m_signal_insert)
|
for (auto& slot : m_signal_insert)
|
||||||
slot(*itr);
|
slot(*itr);
|
||||||
|
|
||||||
itr->add_done_slot(torrent::this_thread::thread(), [this, itr]() { erase(itr); });
|
itr->add_done_slot(torrent::this_thread::thread(), [this, itr]() { erase(itr); });
|
||||||
itr->add_failed_slot(torrent::this_thread::thread(), [this, itr](auto) { erase(itr); });
|
itr->add_failed_slot(torrent::this_thread::thread(), [this, itr](auto) { erase(itr); });
|
||||||
|
|
||||||
|
itr->add_done_slot(torrent::this_thread::thread(), std::move(done_fn));
|
||||||
|
itr->add_failed_slot(torrent::this_thread::thread(), std::move(failed_fn));
|
||||||
|
|
||||||
// TODO: Downloading http torrents doesn't seem to work.
|
// TODO: Downloading http torrents doesn't seem to work.
|
||||||
// TODO: Quitting no longer works.
|
// TODO: Quitting no longer works.
|
||||||
|
|
||||||
|
|||||||
@@ -39,7 +39,8 @@ public:
|
|||||||
//
|
//
|
||||||
// Consider adding a flag to indicate whetever HttpQueue should
|
// Consider adding a flag to indicate whetever HttpQueue should
|
||||||
// delete the stream.
|
// delete the stream.
|
||||||
iterator insert(const std::string& url, std::shared_ptr<std::ostream> stream);
|
iterator insert(const std::string& url, std::shared_ptr<std::ostream> stream,
|
||||||
|
std::function<void()> done_fn, std::function<void(const std::string&)> failed_fn);
|
||||||
void erase(iterator itr);
|
void erase(iterator itr);
|
||||||
|
|
||||||
void clear();
|
void clear();
|
||||||
|
|||||||
Reference in New Issue
Block a user