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 Oct 22, 2021
1 parent 9e4c779 commit bee6408
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 bee6408

Please sign in to comment.