commented out an expensive invariant check. Fixed http parser to accept responses with only LF (and not CRLF)

This commit is contained in:
Arvid Norberg 2006-12-29 23:40:56 +00:00
parent 1561baf1bb
commit a78ef76592
3 changed files with 12 additions and 5 deletions

View File

@ -142,10 +142,11 @@ namespace libtorrent
while (newline != recv_buffer.end && m_state == read_header) while (newline != recv_buffer.end && m_state == read_header)
{ {
if (newline == pos) // if the LF character is preceeded by a CR
throw std::runtime_error("unexpected newline in HTTP response"); // charachter, don't copy it into the line string.
char const* line_end = newline;
line.assign(pos, newline - 1); if (pos != line_end && *(line_end - 1) == '\r') --line_end;
line.assign(pos, line_end);
m_recv_pos += newline - pos; m_recv_pos += newline - pos;
boost::get<1>(ret) += newline - pos; boost::get<1>(ret) += newline - pos;
pos = newline; pos = newline;
@ -153,6 +154,9 @@ namespace libtorrent
std::string::size_type separator = line.find(": "); std::string::size_type separator = line.find(": ");
if (separator == std::string::npos) if (separator == std::string::npos)
{ {
// this means we got a blank line,
// the header is finished and the body
// starts.
++pos; ++pos;
++m_recv_pos; ++m_recv_pos;
boost::get<1>(ret) += 1; boost::get<1>(ret) += 1;

View File

@ -2161,6 +2161,8 @@ namespace libtorrent
assert(false); assert(false);
} }
// expensive when using checked iterators
/*
if (t->valid_metadata()) if (t->valid_metadata())
{ {
int piece_count = std::count(m_have_piece.begin() int piece_count = std::count(m_have_piece.begin()
@ -2170,7 +2172,7 @@ namespace libtorrent
assert(false); assert(false);
} }
} }
*/
assert(m_write_pos <= int(m_send_buffer[ assert(m_write_pos <= int(m_send_buffer[
(m_current_send_buffer + 1) & 1].size())); (m_current_send_buffer + 1) & 1].size()));

View File

@ -245,6 +245,7 @@ namespace libtorrent { namespace detail
catch (const std::exception& e) catch (const std::exception& e)
{ {
// This will happen if the storage fails to initialize // This will happen if the storage fails to initialize
// for example if one of the files has an invalid filename.
session_impl::mutex_t::scoped_lock l(m_ses.m_mutex); session_impl::mutex_t::scoped_lock l(m_ses.m_mutex);
mutex::scoped_lock l2(m_mutex); mutex::scoped_lock l2(m_mutex);