Related to #298: fixed chunk transfer read when only end of chunk remains unread
This commit is contained in:
parent
9cdfe80ce6
commit
eff3b76aa5
2 changed files with 30 additions and 1 deletions
|
|
@ -749,6 +749,21 @@ namespace SimpleWeb {
|
||||||
session->callback(ec);
|
session->callback(ec);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
else if(2 + chunk_size > num_additional_bytes) { // If only end of chunk remains unread (\n or \r\n)
|
||||||
|
// Remove "\r\n"
|
||||||
|
if(2 + chunk_size - num_additional_bytes == 1)
|
||||||
|
istream.get();
|
||||||
|
auto null_buffer = std::make_shared<asio::streambuf>(2);
|
||||||
|
asio::async_read(*session->connection->socket, *null_buffer, asio::transfer_exactly(2 + chunk_size - num_additional_bytes), [this, session, chunk_size_streambuf, null_buffer](const error_code &ec, size_t /*bytes_transferred*/) {
|
||||||
|
auto lock = session->connection->handler_runner->continue_lock();
|
||||||
|
if(!lock)
|
||||||
|
return;
|
||||||
|
if(!ec)
|
||||||
|
read_chunked_transfer_encoded(session, chunk_size_streambuf);
|
||||||
|
else
|
||||||
|
session->callback(ec);
|
||||||
|
});
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
// Remove "\r\n"
|
// Remove "\r\n"
|
||||||
istream.get();
|
istream.get();
|
||||||
|
|
|
||||||
|
|
@ -650,7 +650,6 @@ namespace SimpleWeb {
|
||||||
auto lock = session->connection->handler_runner->continue_lock();
|
auto lock = session->connection->handler_runner->continue_lock();
|
||||||
if(!lock)
|
if(!lock)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(!ec)
|
if(!ec)
|
||||||
read_chunked_transfer_encoded(session, chunk_size_streambuf);
|
read_chunked_transfer_encoded(session, chunk_size_streambuf);
|
||||||
else
|
else
|
||||||
|
|
@ -661,6 +660,21 @@ namespace SimpleWeb {
|
||||||
this->on_error(session->request, ec);
|
this->on_error(session->request, ec);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
else if(2 + chunk_size > num_additional_bytes) { // If only end of chunk remains unread (\n or \r\n)
|
||||||
|
// Remove "\r\n"
|
||||||
|
if(2 + chunk_size - num_additional_bytes == 1)
|
||||||
|
istream.get();
|
||||||
|
auto null_buffer = std::make_shared<asio::streambuf>(2);
|
||||||
|
asio::async_read(*session->connection->socket, *null_buffer, asio::transfer_exactly(2 + chunk_size - num_additional_bytes), [this, session, chunk_size_streambuf, null_buffer](const error_code &ec, size_t /*bytes_transferred*/) {
|
||||||
|
auto lock = session->connection->handler_runner->continue_lock();
|
||||||
|
if(!lock)
|
||||||
|
return;
|
||||||
|
if(!ec)
|
||||||
|
read_chunked_transfer_encoded(session, chunk_size_streambuf);
|
||||||
|
else
|
||||||
|
this->on_error(session->request, ec);
|
||||||
|
});
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
// Remove "\r\n"
|
// Remove "\r\n"
|
||||||
istream.get();
|
istream.get();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue