summaryrefslogtreecommitdiff
path: root/xs_httpd.h
diff options
context:
space:
mode:
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 @@
5#define _XS_HTTPD_H 5#define _XS_HTTPD_H
6 6
7xs_dict *xs_httpd_request(FILE *f, xs_str **payload, int *p_size); 7xs_dict *xs_httpd_request(FILE *f, xs_str **payload, int *p_size);
8void xs_httpd_response(FILE *f, int status, const char *status_text, xs_dict *headers, xs_str *body, int b_size); 8void xs_httpd_response(FILE *f, int status, const char *status_text,
9 const xs_dict *headers, const xs_val *body, int b_size);
9 10
10 11
11#ifdef XS_IMPLEMENTATION 12#ifdef XS_IMPLEMENTATION
@@ -109,16 +110,15 @@ xs_dict *xs_httpd_request(FILE *f, xs_str **payload, int *p_size)
109} 110}
110 111
111 112
112void xs_httpd_response(FILE *f, int status, const char *status_text, xs_dict *headers, xs_str *body, int b_size) 113void xs_httpd_response(FILE *f, int status, const char *status_text,
114 const xs_dict *headers, const xs_val *body, int b_size)
113/* sends an httpd response */ 115/* sends an httpd response */
114{ 116{
115 xs *proto; 117 fprintf(f, "HTTP/1.1 %d %s\r\n", status, status_text ? status_text : "");
118
116 const xs_str *k; 119 const xs_str *k;
117 const xs_val *v; 120 const xs_val *v;
118 121
119 proto = xs_fmt("HTTP/1.1 %d %s", status, status_text);
120 fprintf(f, "%s\r\n", proto);
121
122 xs_dict_foreach(headers, k, v) { 122 xs_dict_foreach(headers, k, v) {
123 fprintf(f, "%s: %s\r\n", k, v); 123 fprintf(f, "%s: %s\r\n", k, v);
124 } 124 }