aboutsummaryrefslogtreecommitdiff
path: root/xs_httpd.h
diff options
context:
space:
mode:
authorgrunfink <grunfink@comam.es>2025-07-08 17:30:45 +0200
committergrunfink <grunfink@comam.es>2025-07-08 17:30:45 +0200
commit08f03cde6b469428494d3870ac54f740fd4641c4 (patch)
treeb537c9c4b26e60eff3f563efb1f950edcf791ce9 /xs_httpd.h
parent1417ffd9dc6aab00898d1ce346742ec4250e657a (diff)
Added some const here and there.
Diffstat (limited to 'xs_httpd.h')
-rw-r--r--xs_httpd.h12
1 files changed, 6 insertions, 6 deletions
diff --git a/xs_httpd.h b/xs_httpd.h
index 4cc8263..57759c4 100644
--- a/xs_httpd.h
+++ b/xs_httpd.h
@@ -5,7 +5,8 @@
#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, const char *status_text, xs_dict *headers, xs_str *body, int b_size);
+void xs_httpd_response(FILE *f, int status, const char *status_text,
+ const xs_dict *headers, const xs_val *body, int b_size);
#ifdef XS_IMPLEMENTATION
@@ -109,16 +110,15 @@ xs_dict *xs_httpd_request(FILE *f, xs_str **payload, int *p_size)
}
-void xs_httpd_response(FILE *f, int status, const char *status_text, xs_dict *headers, xs_str *body, int b_size)
+void xs_httpd_response(FILE *f, int status, const char *status_text,
+ const xs_dict *headers, const xs_val *body, int b_size)
/* sends an httpd response */
{
- xs *proto;
+ fprintf(f, "HTTP/1.1 %d %s\r\n", status, status_text ? status_text : "");
+
const xs_str *k;
const xs_val *v;
- proto = xs_fmt("HTTP/1.1 %d %s", status, status_text);
- fprintf(f, "%s\r\n", proto);
-
xs_dict_foreach(headers, k, v) {
fprintf(f, "%s: %s\r\n", k, v);
}