diff options
| author | 2024-05-27 16:25:20 +0200 | |
|---|---|---|
| committer | 2024-05-27 19:01:04 +0200 | |
| commit | 26fbda787d0d5c8ba9259f79f4d2f937bd6c8ead (patch) | |
| tree | 8615eda88a882eb4959abf707a693374f22d9752 /snac.c | |
| parent | Use ISO C99 __func__ instead of GNU __FUNCTION__ (diff) | |
| download | penes-snac2-26fbda787d0d5c8ba9259f79f4d2f937bd6c8ead.tar.gz penes-snac2-26fbda787d0d5c8ba9259f79f4d2f937bd6c8ead.tar.xz penes-snac2-26fbda787d0d5c8ba9259f79f4d2f937bd6c8ead.zip | |
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.
Diffstat (limited to '')
| -rw-r--r-- | snac.c | 12 |
1 files changed, 12 insertions, 0 deletions
| @@ -170,3 +170,15 @@ int check_password(const char *uid, const char *passwd, const char *hash) | |||
| 170 | 170 | ||
| 171 | return ret; | 171 | return ret; |
| 172 | } | 172 | } |
| 173 | |||
| 174 | |||
| 175 | const char *http_status_text(int status) | ||
| 176 | /* translate status codes to canonical status texts */ | ||
| 177 | { | ||
| 178 | switch (status) { | ||
| 179 | #define HTTP_STATUS(code, name, text) case HTTP_STATUS_ ## name: return #text; | ||
| 180 | #include "http_codes.h" | ||
| 181 | #undef HTTP_STATUS | ||
| 182 | default: return "Unknown"; | ||
| 183 | } | ||
| 184 | } | ||