From bee6408a2512c12669237d970b13cb0b0be87278 Mon Sep 17 00:00:00 2001 From: mikee47 Date: Mon, 11 Oct 2021 08:39:15 +0100 Subject: [PATCH] Ensure request callback is invoked on client connection error --- .../src/Network/Http/HttpClientConnection.cpp | 14 ++++++++++++++ .../src/Network/Http/HttpClientConnection.h | 1 + 2 files changed, 15 insertions(+) diff --git a/Sming/Components/Network/src/Network/Http/HttpClientConnection.cpp b/Sming/Components/Network/src/Network/Http/HttpClientConnection.cpp index cac3f32ce5..82f49b1b25 100644 --- a/Sming/Components/Network/src/Network/Http/HttpClientConnection.cpp +++ b/Sming/Components/Network/src/Network/Http/HttpClientConnection.cpp @@ -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(); diff --git a/Sming/Components/Network/src/Network/Http/HttpClientConnection.h b/Sming/Components/Network/src/Network/Http/HttpClientConnection.h index 0cf6301080..69edc23b22 100644 --- a/Sming/Components/Network/src/Network/Http/HttpClientConnection.h +++ b/Sming/Components/Network/src/Network/Http/HttpClientConnection.h @@ -68,6 +68,7 @@ class HttpClientConnection : public HttpConnection // TCP methods void onReadyToSendData(TcpConnectionEvent sourceEvent) override; + void onError(err_t err) override; void onClosed() override;