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. --- http_codes.h | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 http_codes.h (limited to 'http_codes.h') diff --git a/http_codes.h b/http_codes.h new file mode 100644 index 0000000..795f92a --- /dev/null +++ b/http_codes.h @@ -0,0 +1,45 @@ +HTTP_STATUS(100, CONTINUE, Continue) +HTTP_STATUS(101, SWITCHING_PROTOCOLS, Switching Protocols) +HTTP_STATUS(102, PROCESSING, Processing) +HTTP_STATUS(103, EARLY_HINTS, Early Hints) +HTTP_STATUS(200, OK, OK) +HTTP_STATUS(201, CREATED, Created) +HTTP_STATUS(202, ACCEPTED, Accepted) +HTTP_STATUS(203, NON_AUTHORITATIVE_INFORMATION, Non Authoritative Information) +HTTP_STATUS(204, NO_CONTENT, No Content) +HTTP_STATUS(205, RESET_CONTENT, Reset Content) +HTTP_STATUS(206, PARTIAL_CONTENT, Partial Content) +HTTP_STATUS(207, MULTI_STATUS, Multi Status) +HTTP_STATUS(208, ALREADY_REPORTED, Already Reported) +HTTP_STATUS(218, THIS_IS_FINE, This Is Fine) +HTTP_STATUS(226, IM_USED, IM Used) +HTTP_STATUS(300, MULTIPLE_CHOICES, Multiple Choices) +HTTP_STATUS(301, MOVED_PERMANENTLY, Moved Permanently) +HTTP_STATUS(302, FOUND, Found) +HTTP_STATUS(303, SEE_OTHER, See Other) +HTTP_STATUS(304, NOT_MODIFIED, Not Modified) +HTTP_STATUS(305, USE_PROXY, Use Proxy) +HTTP_STATUS(306, SWITCH_PROXY, Switch Proxy) +HTTP_STATUS(307, TEMPORARY_REDIRECT, Temporary Redirect) +HTTP_STATUS(308, PERMANENT_REDIRECT, Permanent Redirect) +HTTP_STATUS(400, BAD_REQUEST, Bad Request) +HTTP_STATUS(401, UNAUTHORIZED, Unauthorized) +HTTP_STATUS(402, PAYMENT_REQUIRED, Payment Required) +HTTP_STATUS(403, FORBIDDEN, Forbidden) +HTTP_STATUS(404, NOT_FOUND, Not Found) +HTTP_STATUS(405, METHOD_NOT_ALLOWED, Method Not Allowed) +HTTP_STATUS(406, NOT_ACCEPTABLE, Not Acceptable) +HTTP_STATUS(407, PROXY_AUTHENTICATION_REQUIRED, Proxy Authentication Required) +HTTP_STATUS(408, REQUEST_TIMEOUT, Request Timeout) +HTTP_STATUS(409, CONFLICT, Conflict) +HTTP_STATUS(410, GONE, Gone) +HTTP_STATUS(421, MISDIRECTED_REQUEST, Misdirected Request) +HTTP_STATUS(422, UNPROCESSABLE_CONTENT, Unprocessable Content) +HTTP_STATUS(499, CLIENT_CLOSED_REQUEST, Client Closed Request) +HTTP_STATUS(500, INTERNAL_SERVER_ERROR, Internal Server Error) +HTTP_STATUS(501, NOT_IMPLEMENTED, Not Implemented) +HTTP_STATUS(502, BAD_GATEWAY, Bad Gateway) +HTTP_STATUS(503, SERVICE_UNAVAILABLE, Service Unavailable) +HTTP_STATUS(504, GATEWAY_TIMEOUT, Gateway Timeout) +HTTP_STATUS(505, HTTP_VERSION_NOT_SUPPORTED, HTTP Version Not Supported) +HTTP_STATUS(507, INSUFFICIENT_STORAGE, Insufficient Storage) \ No newline at end of file -- cgit v1.2.3 From 25ef07b1ec7576becc02bcfc07706184797fea91 Mon Sep 17 00:00:00 2001 From: Louis Brauer Date: Mon, 27 May 2024 23:55:51 +0200 Subject: More or less smaller fixes :) --- Makefile | 2 +- http_codes.h | 2 +- mastoapi.c | 1 + xs_set.h | 2 +- 4 files changed, 4 insertions(+), 3 deletions(-) (limited to 'http_codes.h') diff --git a/Makefile b/Makefile index 1edf99e..5a59d6b 100644 --- a/Makefile +++ b/Makefile @@ -52,7 +52,7 @@ mastoapi.o: mastoapi.c xs.h xs_hex.h xs_openssl.h xs_json.h xs_io.h \ snac.o: snac.c xs.h xs_hex.h xs_io.h xs_unicode.h xs_json.h xs_curl.h \ xs_openssl.h xs_socket.h xs_url.h xs_httpd.h xs_mime.h xs_regex.h \ xs_set.h xs_time.h xs_glob.h xs_random.h xs_match.h xs_fcgi.h xs_html.h \ - snac.h + snac.h http_codes.h upgrade.o: upgrade.c xs.h xs_io.h xs_json.h xs_glob.h snac.h utils.o: utils.c xs.h xs_io.h xs_json.h xs_time.h xs_openssl.h \ xs_random.h xs_glob.h xs_curl.h xs_regex.h snac.h diff --git a/http_codes.h b/http_codes.h index 795f92a..a1958f1 100644 --- a/http_codes.h +++ b/http_codes.h @@ -42,4 +42,4 @@ HTTP_STATUS(502, BAD_GATEWAY, Bad Gateway) HTTP_STATUS(503, SERVICE_UNAVAILABLE, Service Unavailable) HTTP_STATUS(504, GATEWAY_TIMEOUT, Gateway Timeout) HTTP_STATUS(505, HTTP_VERSION_NOT_SUPPORTED, HTTP Version Not Supported) -HTTP_STATUS(507, INSUFFICIENT_STORAGE, Insufficient Storage) \ No newline at end of file +HTTP_STATUS(507, INSUFFICIENT_STORAGE, Insufficient Storage) diff --git a/mastoapi.c b/mastoapi.c index 32f6bae..0adba08 100644 --- a/mastoapi.c +++ b/mastoapi.c @@ -1466,6 +1466,7 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path, /* we don't serve statuses of others; return the empty list */ out = xs_list_new(); } + else if (strcmp(opt, "featured_tags") == 0) { /* snac doesn't have features tags, yet? */ /* implement empty response so apps like Tokodon don't show an error */ diff --git a/xs_set.h b/xs_set.h index d320d34..6ab7f0b 100644 --- a/xs_set.h +++ b/xs_set.h @@ -111,4 +111,4 @@ int xs_set_add(xs_set *s, const xs_val *data) #endif /* XS_IMPLEMENTATION */ -#endif /* XS_SET_H */ \ No newline at end of file +#endif /* XS_SET_H */ -- cgit v1.2.3