From 26fbda787d0d5c8ba9259f79f4d2f937bd6c8ead Mon Sep 17 00:00:00 2001 From: Louis Brauer Date: Mon, 27 May 2024 16:25:20 +0200 Subject: Translate status codes to canonical status texts Use those in HTTP responses instead of "OK"/"ERROR". Apps like Tokodon show only the status text in unexpected responses. --- snac.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'snac.c') diff --git a/snac.c b/snac.c index 5ba98e1..0df8691 100644 --- a/snac.c +++ b/snac.c @@ -170,3 +170,15 @@ int check_password(const char *uid, const char *passwd, const char *hash) return ret; } + + +const char *http_status_text(int status) +/* translate status codes to canonical status texts */ +{ + switch (status) { +#define HTTP_STATUS(code, name, text) case HTTP_STATUS_ ## name: return #text; +#include "http_codes.h" +#undef HTTP_STATUS + default: return "Unknown"; + } +} -- cgit v1.2.3