summaryrefslogtreecommitdiff
path: root/xs_httpd.h
diff options
context:
space:
mode:
authorLouis Brauer <louis@openbooking.ch>2024-05-27 16:25:20 +0200
committerLouis Brauer <louis@openbooking.ch>2024-05-27 19:01:04 +0200
commit26fbda787d0d5c8ba9259f79f4d2f937bd6c8ead (patch)
tree8615eda88a882eb4959abf707a693374f22d9752 /xs_httpd.h
parent637a88fb0f20aa5aad2dcd66ec7ec7b39f7af0e2 (diff)
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 'xs_httpd.h')
-rw-r--r--xs_httpd.h6
1 files changed, 3 insertions, 3 deletions
diff --git a/xs_httpd.h b/xs_httpd.h
index 4195b81..d080b39 100644
--- a/xs_httpd.h
+++ b/xs_httpd.h
@@ -5,7 +5,7 @@
#define _XS_HTTPD_H
xs_dict *xs_httpd_request(FILE *f, xs_str **payload, int *p_size);
-void xs_httpd_response(FILE *f, int status, xs_dict *headers, xs_str *body, int b_size);
+void xs_httpd_response(FILE *f, int status, const char *status_text, xs_dict *headers, xs_str *body, int b_size);
#ifdef XS_IMPLEMENTATION
@@ -95,14 +95,14 @@ xs_dict *xs_httpd_request(FILE *f, xs_str **payload, int *p_size)
}
-void xs_httpd_response(FILE *f, int status, xs_dict *headers, xs_str *body, int b_size)
+void xs_httpd_response(FILE *f, int status, const char *status_text, xs_dict *headers, xs_str *body, int b_size)
/* sends an httpd response */
{
xs *proto;
const xs_str *k;
const xs_val *v;
- proto = xs_fmt("HTTP/1.1 %d %s", status, status / 100 == 2 ? "OK" : "ERROR");
+ proto = xs_fmt("HTTP/1.1 %d %s", status, status_text);
fprintf(f, "%s\r\n", proto);
int c = 0;