commit 08f03cd
grunfink
·
2025-07-08 15:30:45 +0000 UTC
parent 1417ffd
Added some const here and there.
5 files changed,
+11,
-11
M
snac.h
+1,
-1
1@@ -325,7 +325,7 @@ void httpd(void);
2 int webfinger_request_signed(snac *snac, const char *qs, xs_str **actor, xs_str **user);
3 int webfinger_request(const char *qs, xs_str **actor, xs_str **user);
4 int webfinger_request_fake(const char *qs, xs_str **actor, xs_str **user);
5-int webfinger_get_handler(xs_dict *req, const char *q_path,
6+int webfinger_get_handler(const xs_dict *req, const char *q_path,
7 xs_val **body, int *b_size, char **ctype);
8
9 const char *default_avatar_base64(void);
+1,
-1
1@@ -152,7 +152,7 @@ int webfinger_request_fake(const char *qs, xs_str **actor, xs_str **user)
2 }
3
4
5-int webfinger_get_handler(xs_dict *req, const char *q_path,
6+int webfinger_get_handler(const xs_dict *req, const char *q_path,
7 xs_val **body, int *b_size, char **ctype)
8 /* serves webfinger queries */
9 {
+2,
-2
1@@ -13,7 +13,7 @@
2 #define _XS_FCGI_H
3
4 xs_dict *xs_fcgi_request(FILE *f, xs_str **payload, int *p_size, int *id);
5- void xs_fcgi_response(FILE *f, int status, xs_dict *headers, xs_str *body, int b_size, int id);
6+ void xs_fcgi_response(FILE *f, int status, const xs_dict *headers, const xs_str *body, int b_size, int id);
7
8
9 #ifdef XS_IMPLEMENTATION
10@@ -290,7 +290,7 @@ end:
11 }
12
13
14-void xs_fcgi_response(FILE *f, int status, xs_dict *headers, xs_str *body, int b_size, int fcgi_id)
15+void xs_fcgi_response(FILE *f, int status, const xs_dict *headers, const xs_str *body, int b_size, int fcgi_id)
16 /* writes an FCGI response */
17 {
18 struct fcgi_record_header hdr = {0};
+6,
-6
1@@ -5,7 +5,8 @@
2 #define _XS_HTTPD_H
3
4 xs_dict *xs_httpd_request(FILE *f, xs_str **payload, int *p_size);
5-void xs_httpd_response(FILE *f, int status, const char *status_text, xs_dict *headers, xs_str *body, int b_size);
6+void xs_httpd_response(FILE *f, int status, const char *status_text,
7+ const xs_dict *headers, const xs_val *body, int b_size);
8
9
10 #ifdef XS_IMPLEMENTATION
11@@ -109,16 +110,15 @@ xs_dict *xs_httpd_request(FILE *f, xs_str **payload, int *p_size)
12 }
13
14
15-void xs_httpd_response(FILE *f, int status, const char *status_text, xs_dict *headers, xs_str *body, int b_size)
16+void xs_httpd_response(FILE *f, int status, const char *status_text,
17+ const xs_dict *headers, const xs_val *body, int b_size)
18 /* sends an httpd response */
19 {
20- xs *proto;
21+ fprintf(f, "HTTP/1.1 %d %s\r\n", status, status_text ? status_text : "");
22+
23 const xs_str *k;
24 const xs_val *v;
25
26- proto = xs_fmt("HTTP/1.1 %d %s", status, status_text);
27- fprintf(f, "%s\r\n", proto);
28-
29 xs_dict_foreach(headers, k, v) {
30 fprintf(f, "%s: %s\r\n", k, v);
31 }
+1,
-1
1@@ -1 +1 @@
2-/* a32c0d513ae24ad28ffc5c6c2c1cde75bb758e09 2025-06-23T17:43:10+02:00 */
3+/* 401d229ffbec89b4a5cf97793926b7afb84a4f26 2025-07-08T15:44:54+02:00 */