]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-http: Use explicit numbers for HTTP_CLIENT_REQUEST_ERROR_* codes
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Thu, 15 May 2025 09:48:41 +0000 (12:48 +0300)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Mon, 19 May 2025 16:46:24 +0000 (16:46 +0000)
We're beginning on rely on these numbers not to change, so make the numbers
explicit to avoid accidental changes.

src/lib-http/http-client.c
src/lib-http/http-client.h

index 85c34df79383587f3646742e68fb60aaba720f7b..7f3901ad2f93aecdc596c97c4b9c06ea74364da8 100644 (file)
@@ -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
  */
index 006f676759cdce99ad08e6dc2b3cd992dbf21da3..4d83499fc28b84c43da537b5750ad3b5a30511fe 100644 (file)
@@ -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 {