merged chunked encoding fix from RC_0_16

This commit is contained in:
Arvid Norberg 2014-01-21 09:14:00 +00:00
parent ca132efeb1
commit 5d3c479e12
2 changed files with 16 additions and 12 deletions

View File

@ -39,6 +39,7 @@
* fix uTP edge case where udp socket buffer fills up
* fix nagle implementation in uTP
* HTTP chunked encoding fix
* expose file_granularity flag to python bindings
* fix DHT memory error
* change semantics of storage allocation to allocate on first write rather

View File

@ -643,18 +643,6 @@ namespace libtorrent
}
}
if (m_requests.empty() || m_file_requests.empty())
{
m_statistics.received_bytes(0, bytes_transferred);
disconnect(errors::http_error, 2);
#ifdef TORRENT_DEBUG
TORRENT_ASSERT(m_statistics.last_payload_downloaded()
+ m_statistics.last_protocol_downloaded()
== dl_target);
#endif
return;
}
// =========================
// === CHUNKED ENCODING ===
// =========================
@ -702,9 +690,24 @@ namespace libtorrent
#endif
m_chunk_pos = -1;
}
// if all of hte receive buffer was just consumed as chunk
// header, we're done
if (bytes_transferred == 0) return;
}
}
if (m_requests.empty() || m_file_requests.empty())
{
m_statistics.received_bytes(0, bytes_transferred);
disconnect(errors::http_error, 2);
#ifdef TORRENT_DEBUG
TORRENT_ASSERT(m_statistics.last_payload_downloaded()
+ m_statistics.last_protocol_downloaded()
== dl_target);
#endif
return;
}
size_type left_in_response = range_end - range_start - m_range_pos;
int payload_transferred = int((std::min)(left_in_response, size_type(bytes_transferred)));