Fix bug in HttpClient where it wouldn't retry on EAGAIN.

This commit is contained in:
Jordan Bancino 2023-03-24 00:23:49 +00:00
parent 20d41d794b
commit fe32c652cd

View file

@ -29,6 +29,7 @@
#include <ctype.h> #include <ctype.h>
#include <unistd.h> #include <unistd.h>
#include <errno.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <netdb.h> #include <netdb.h>
@ -201,6 +202,18 @@ HttpRequestSend(HttpClientContext * context)
lineLen = UtilGetLine(&line, &lineSize, context->stream); 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" */ /* Line must contain at least "HTTP/x.x xxx" */
if (lineLen < 12) if (lineLen < 12)
{ {