From 0fd3d8f4c739f3f849aecf90ac99d2a726177199 Mon Sep 17 00:00:00 2001 From: Stephan Bosch Date: Thu, 19 Nov 2020 12:47:19 +0100 Subject: [PATCH] lib-http: http-client-connection - Restructure http_client_connection_handle_response() --- src/lib-http/http-client-connection.c | 81 +++++++++++++-------------- 1 file changed, 39 insertions(+), 42 deletions(-) diff --git a/src/lib-http/http-client-connection.c b/src/lib-http/http-client-connection.c index f7f403db05..4f860625eb 100644 --- a/src/lib-http/http-client-connection.c +++ b/src/lib-http/http-client-connection.c @@ -955,49 +955,46 @@ http_client_connection_handle_response(struct http_client_connection *conn, { struct http_client_peer_shared *pshared = conn->ppool->peer; - /* Don't redirect/retry if we're sending data in small blocks - via http_client_request_send_payload() and we're not waiting - for 100 continue */ - if (!req->payload_wait || - (req->payload_sync && !req->payload_sync_continue)) { - /* Failed Expect: */ - if (resp->status == 417 && req->payload_sync) { - /* Drop Expect: continue */ - req->payload_sync = FALSE; - conn->output_locked = FALSE; - pshared->no_payload_sync = TRUE; - if (http_client_request_try_retry(req)) - return TRUE; - /* Redirection */ - } else if (req->client->set->auto_redirect && - resp->status / 100 == 3 && - resp->status != 304 && - resp->location != NULL) { - /* Redirect (possibly after delay) */ - if (http_client_request_delay_from_response( - req, resp) >= 0) { - http_client_request_redirect( - req, resp->status, resp->location); - return TRUE; - } - /* Service unavailable */ - } else if (resp->status == 503) { - /* Automatically retry after delay if indicated - */ - if (resp->retry_after != (time_t)-1 && - http_client_request_delay_from_response( - req, resp) > 0 && - http_client_request_try_retry(req)) - return TRUE; - /* Request timeout (by server) */ - } else if (resp->status == 408) { - /* Automatically retry */ - if (http_client_request_try_retry(req)) - return TRUE; - /* Connection close is implicit, although server - should indicate that explicitly */ - conn->close_indicated = TRUE; + /* Don't redirect/retry if we're sending data in small blocks via + http_client_request_send_payload() and we're not waiting for + 100-continue. */ + if (req->payload_wait && + (!req->payload_sync || req->payload_sync_continue)) + return FALSE; + + /* Failed Expect: */ + if (resp->status == 417 && req->payload_sync) { + /* Drop Expect: continue */ + req->payload_sync = FALSE; + conn->output_locked = FALSE; + pshared->no_payload_sync = TRUE; + if (http_client_request_try_retry(req)) + return TRUE; + /* Redirection */ + } else if (req->client->set->auto_redirect && + resp->status / 100 == 3 && resp->status != 304 && + resp->location != NULL) { + /* Redirect (possibly after delay) */ + if (http_client_request_delay_from_response(req, resp) >= 0) { + http_client_request_redirect(req, resp->status, + resp->location); + return TRUE; } + /* Service unavailable */ + } else if (resp->status == 503) { + /* Automatically retry after delay if indicated */ + if (resp->retry_after != (time_t)-1 && + http_client_request_delay_from_response(req, resp) > 0 && + http_client_request_try_retry(req)) + return TRUE; + /* Request timeout (by server) */ + } else if (resp->status == 408) { + /* Automatically retry */ + if (http_client_request_try_retry(req)) + return TRUE; + /* Connection close is implicit, although server should indicate + that explicitly */ + conn->close_indicated = TRUE; } return FALSE; } -- 2.47.3