From b284962364068d5e9d60b8b1e98ba61b4b6593ec Mon Sep 17 00:00:00 2001 From: Stephan Bosch Date: Wed, 9 Nov 2016 00:46:32 +0100 Subject: [PATCH] lib-http: client: Fixed assert failure occurring when server returns error status early while client is still sending blocking payload. --- src/lib-http/http-client-request.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/lib-http/http-client-request.c b/src/lib-http/http-client-request.c index 771181f8df..625349bfe8 100644 --- a/src/lib-http/http-client-request.c +++ b/src/lib-http/http-client-request.c @@ -821,10 +821,16 @@ int http_client_request_send_payload(struct http_client_request **_req, i_assert(data != NULL); ret = http_client_request_continue_payload(&req, data, size); - if (ret < 0) + if (ret < 0) { + /* failed to send payload */ *_req = NULL; - else { - i_assert(ret == 0); + } else if (ret > 0) { + /* premature end of request; + server sent error before all payload could be sent */ + ret = -1; + *_req = NULL; + } else { + /* not finished sending payload */ i_assert(req != NULL); } return ret;