From: Timo Sirainen Date: Thu, 15 May 2025 09:48:41 +0000 (+0300) Subject: lib-http: Use explicit numbers for HTTP_CLIENT_REQUEST_ERROR_* codes X-Git-Tag: 2.4.2~766 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e133fa58d6a40209dd96f47ad4aec871b4661801;p=thirdparty%2Fdovecot%2Fcore.git lib-http: Use explicit numbers for HTTP_CLIENT_REQUEST_ERROR_* codes We're beginning on rely on these numbers not to change, so make the numbers explicit to avoid accidental changes. --- diff --git a/src/lib-http/http-client.c b/src/lib-http/http-client.c index 85c34df793..7f3901ad2f 100644 --- a/src/lib-http/http-client.c +++ b/src/lib-http/http-client.c @@ -99,6 +99,9 @@ static void http_client_context_remove_client(struct http_client_context *cctx, struct http_client *client); +static_assert(HTTP_CLIENT_REQUEST_ERROR_ABORTED == HTTP_RESPONSE_STATUS_INTERNAL, + "Internal HTTP response code numbers are inconsistent"); + /* * Client */ diff --git a/src/lib-http/http-client.h b/src/lib-http/http-client.h index 006f676759..4d83499fc2 100644 --- a/src/lib-http/http-client.h +++ b/src/lib-http/http-client.h @@ -152,28 +152,28 @@ extern const struct setting_parser_info http_client_setting_parser_info; enum http_client_request_error { /* The request was aborted. */ - HTTP_CLIENT_REQUEST_ERROR_ABORTED = HTTP_RESPONSE_STATUS_INTERNAL, + HTTP_CLIENT_REQUEST_ERROR_ABORTED = 9000, /* Failed to parse HTTP target url. */ - HTTP_CLIENT_REQUEST_ERROR_INVALID_URL, + HTTP_CLIENT_REQUEST_ERROR_INVALID_URL = 9001, /* Failed to perform DNS lookup for the host. */ - HTTP_CLIENT_REQUEST_ERROR_HOST_LOOKUP_FAILED, + HTTP_CLIENT_REQUEST_ERROR_HOST_LOOKUP_FAILED = 9002, /* Failed to setup any connection for the host and client settings allowed no more attempts. */ - HTTP_CLIENT_REQUEST_ERROR_CONNECT_FAILED, + HTTP_CLIENT_REQUEST_ERROR_CONNECT_FAILED = 9003, /* Service returned an invalid redirect response for this request */ - HTTP_CLIENT_REQUEST_ERROR_INVALID_REDIRECT, + HTTP_CLIENT_REQUEST_ERROR_INVALID_REDIRECT = 9004, /* The connection was lost unexpectedly while handling the request and client settings allowed no more attempts */ - HTTP_CLIENT_REQUEST_ERROR_CONNECTION_LOST, + HTTP_CLIENT_REQUEST_ERROR_CONNECTION_LOST = 9005, /* The input stream passed to the request using http_client_request_set_payload() returned an error while sending the request. */ - HTTP_CLIENT_REQUEST_ERROR_BROKEN_PAYLOAD, + HTTP_CLIENT_REQUEST_ERROR_BROKEN_PAYLOAD = 9006, /* The service returned a bad response. */ - HTTP_CLIENT_REQUEST_ERROR_BAD_RESPONSE, + HTTP_CLIENT_REQUEST_ERROR_BAD_RESPONSE = 9007, /* The request timed out (either this was the last attempt or the absolute timeout was hit) */ - HTTP_CLIENT_REQUEST_ERROR_TIMED_OUT, + HTTP_CLIENT_REQUEST_ERROR_TIMED_OUT = 9008, }; enum http_request_state {