From f358601505374371f24f8e5b50f630a5646bc682 Mon Sep 17 00:00:00 2001 From: Alex Hultman Date: Mon, 18 Nov 2019 22:08:06 +0100 Subject: [PATCH] Fix Http timeout of posted data --- src/HttpContext.h | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/HttpContext.h b/src/HttpContext.h index f13163b31..74e9afd16 100644 --- a/src/HttpContext.h +++ b/src/HttpContext.h @@ -186,9 +186,14 @@ struct HttpContext { /* We always get an empty chunk even if there is no data */ if (httpResponseData->inStream) { - /* Getting a chunk of data while having a data handler should reset timeout (todo: if last, short timeout, if not last, bigger timeout) */ - /* Really, we only need to reset timeout to the larger delay if we are not fin */ - us_socket_timeout(SSL, (struct us_socket_t *) user, HTTP_IDLE_TIMEOUT_S); + /* Todo: can this handle timeout for non-post as well? */ + if (fin) { + /* If we just got the last chunk (or empty chunk), disable timeout */ + us_socket_timeout(SSL, (struct us_socket_t *) user, 0); + } else { + /* We still have some more data coming in later, so reset timeout */ + us_socket_timeout(SSL, (struct us_socket_t *) user, HTTP_IDLE_TIMEOUT_S); + } /* We might respond in the handler, so do not change timeout after this */ httpResponseData->inStream(data, fin);