Skip to content

Commit

Permalink
Ensure request callback is invoked on client connection error
Browse files Browse the repository at this point in the history
  • Loading branch information
mikee47 committed Jun 22, 2024
1 parent 34ec9b2 commit 584e95f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
14 changes: 14 additions & 0 deletions Sming/Components/Network/src/Network/Http/HttpClientConnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,20 @@ void HttpClientConnection::reset()
HttpConnection::reset();
}

void HttpClientConnection::onError(err_t err)
{
HttpConnection::onError(err);

auto request = waitingQueue.peek();

if(request != nullptr) {
auto callback = request->requestCompletedDelegate;
if(callback) {
callback(*this, false);
}
}
}

int HttpClientConnection::onMessageBegin(http_parser* parser)
{
incomingRequest = executionQueue.peek();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ class HttpClientConnection : public HttpConnection

// TCP methods
void onReadyToSendData(TcpConnectionEvent sourceEvent) override;
void onError(err_t err) override;

void onClosed() override;

Expand Down

0 comments on commit 584e95f

Please sign in to comment.