]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-http: Added a function to obtain a message suitable for logging from a response...
authorStephan Bosch <stephan.bosch@dovecot.fi>
Sun, 19 Mar 2017 14:09:03 +0000 (15:09 +0100)
committerGitLab <gitlab@git.dovecot.net>
Wed, 22 Mar 2017 18:41:09 +0000 (20:41 +0200)
This prevents logging internal error codes (>= 9000).

src/lib-http/http-response.h

index 7c5efb1fdf1e739b4667adad8cf8e60aca3db945..c354a867314b19a6d6ceedce46c986ddaeca6dcb 100644 (file)
@@ -59,6 +59,14 @@ http_response_header_get_fields(const struct http_response *resp)
        return http_header_get_fields(resp->header);
 }
 
+static inline const char *
+http_response_get_message(const struct http_response *resp)
+{
+       if (resp->status >= HTTP_RESPONSE_STATUS_INTERNAL)
+               return resp->reason;
+       return t_strdup_printf("%u %s", resp->status, resp->reason);
+}
+
 bool http_response_has_connection_option(const struct http_response *resp,
        const char *option);
 int http_response_get_payload_size(const struct http_response *resp,