forked from premiere/premiere-libtorrent
fixed http_connection error handling and improved http parser
This commit is contained in:
parent
b2dc035a54
commit
7cae5f897b
|
@ -285,7 +285,17 @@ void http_connection::on_read(asio::error_code const& e
|
||||||
{
|
{
|
||||||
libtorrent::buffer::const_interval rcv_buf(&m_recvbuffer[0]
|
libtorrent::buffer::const_interval rcv_buf(&m_recvbuffer[0]
|
||||||
, &m_recvbuffer[0] + m_read_pos);
|
, &m_recvbuffer[0] + m_read_pos);
|
||||||
m_parser.incoming(rcv_buf);
|
try
|
||||||
|
{
|
||||||
|
m_parser.incoming(rcv_buf);
|
||||||
|
}
|
||||||
|
catch (std::exception& e)
|
||||||
|
{
|
||||||
|
m_timer.cancel();
|
||||||
|
m_handler(asio::error::fault, m_parser, 0, 0);
|
||||||
|
m_handler.clear();
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!m_bottled && m_parser.header_finished())
|
if (!m_bottled && m_parser.header_finished())
|
||||||
{
|
{
|
||||||
if (m_read_pos > m_parser.body_start())
|
if (m_read_pos > m_parser.body_start())
|
||||||
|
|
|
@ -204,7 +204,11 @@ namespace libtorrent
|
||||||
char dummy;
|
char dummy;
|
||||||
std::string bytes;
|
std::string bytes;
|
||||||
size_type range_start, range_end;
|
size_type range_start, range_end;
|
||||||
range_str >> bytes >> range_start >> dummy >> range_end;
|
// apparently some web servers do not send the "bytes"
|
||||||
|
// in their content-range
|
||||||
|
if (value.find(' ') != std::string::npos)
|
||||||
|
range_str >> bytes;
|
||||||
|
range_str >> range_start >> dummy >> range_end;
|
||||||
if (!range_str || range_end < range_start)
|
if (!range_str || range_end < range_start)
|
||||||
{
|
{
|
||||||
throw std::runtime_error("invalid content-range in HTTP response: " + range_str.str());
|
throw std::runtime_error("invalid content-range in HTTP response: " + range_str.str());
|
||||||
|
|
Loading…
Reference in New Issue