From fe32c652cda1261c0c3af4dcd86bfded526f9c95 Mon Sep 17 00:00:00 2001 From: Jordan Bancino Date: Fri, 24 Mar 2023 00:23:49 +0000 Subject: [PATCH] Fix bug in HttpClient where it wouldn't retry on EAGAIN. --- src/HttpClient.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/HttpClient.c b/src/HttpClient.c index 06be264..aa4d511 100644 --- a/src/HttpClient.c +++ b/src/HttpClient.c @@ -29,6 +29,7 @@ #include #include +#include #include #include #include @@ -201,6 +202,18 @@ HttpRequestSend(HttpClientContext * context) lineLen = UtilGetLine(&line, &lineSize, context->stream); + while (lineLen == -1 && errno == EAGAIN) + { + StreamClearError(context->stream); + lineLen = UtilGetLine(&line, &lineSize, context->stream); + } + + if (lineLen == -1) + { + Log(LOG_ERR, "HttpRequestSend(): %s", strerror(errno)); + return 0; + } + /* Line must contain at least "HTTP/x.x xxx" */ if (lineLen < 12) {