forked from premiere/premiere-libtorrent
url download fix
This commit is contained in:
parent
71e4172bde
commit
97695d6c1d
|
@ -449,12 +449,15 @@ namespace libtorrent
|
||||||
, http_parser const& parser
|
, http_parser const& parser
|
||||||
, char const* data, int size)
|
, char const* data, int size)
|
||||||
{
|
{
|
||||||
|
if (m_abort) return;
|
||||||
|
|
||||||
if (ec && ec != asio::error::eof)
|
if (ec && ec != asio::error::eof)
|
||||||
{
|
{
|
||||||
set_error(ec, m_url);
|
set_error(ec, m_url);
|
||||||
pause();
|
pause();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (size > 0)
|
if (size > 0)
|
||||||
{
|
{
|
||||||
m_torrent_file_buf.insert(m_torrent_file_buf.end(), data, data + size);
|
m_torrent_file_buf.insert(m_torrent_file_buf.end(), data, data + size);
|
||||||
|
@ -463,6 +466,14 @@ namespace libtorrent
|
||||||
* 1000000 / parser.content_length());
|
* 1000000 / parser.content_length());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (parser.header_finished() && parser.status_code() != 200)
|
||||||
|
{
|
||||||
|
// #error there should really be an error code category for HTTP
|
||||||
|
set_error(errors::http_error, parser.message());
|
||||||
|
pause();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!ec) return;
|
if (!ec) return;
|
||||||
|
|
||||||
std::string const& encoding = parser.header("content-encoding");
|
std::string const& encoding = parser.header("content-encoding");
|
||||||
|
@ -592,7 +603,7 @@ namespace libtorrent
|
||||||
new http_connection(m_ses.m_io_service, m_ses.m_half_open
|
new http_connection(m_ses.m_io_service, m_ses.m_half_open
|
||||||
, boost::bind(&torrent::on_torrent_download, shared_from_this()
|
, boost::bind(&torrent::on_torrent_download, shared_from_this()
|
||||||
, _1, _2, _3, _4), false));
|
, _1, _2, _3, _4), false));
|
||||||
conn->get(m_url);
|
conn->get(m_url, seconds(30), 0, 0, 5, m_ses.m_settings.user_agent);
|
||||||
set_state(torrent_status::downloading_metadata);
|
set_state(torrent_status::downloading_metadata);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue