Skip to content

Commit

Permalink
HttpRequest deduce request success when buffers are empty
Browse files Browse the repository at this point in the history
Signed-off-by: Méven Car <[email protected]>
Change-Id: I70537fb4ed433fceb7efad7e7a393315e1c646f8
  • Loading branch information
meven committed Nov 28, 2024
1 parent 92c9179 commit 38b6c57
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions net/HttpRequest.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1665,19 +1665,27 @@ class Session final : public ProtocolHandlerInterface

void onDisconnect() override
{

bool completed = false;
// Make sure the socket is disconnected and released.
std::shared_ptr<StreamSocket> socket = _socket.lock();
if (socket)
{
completed = socket->getOutBuffer().empty() && socket->getInBuffer().empty();

LOG_TRC("onDisconnect");
socket->shutdown(); // Flag for shutdown for housekeeping in SocketPoll.
socket->closeConnection(); // Immediately disconnect.
_socket.reset();
}

_connected = false;
if (_response)
_response->finish();
if (_response) {
if (completed)
_response->complete();
else
_response->finish();
}

_fd = -1; // No longer our socket fd.
}
Expand Down

0 comments on commit 38b6c57

Please sign in to comment.