From 07be3721c10e96f05c1b18ca3b5c5a151e331e21 Mon Sep 17 00:00:00 2001 From: default Date: Sat, 12 Aug 2023 21:46:54 +0200 Subject: Some mastoapi tweaks to support the semaphore.social web client. --- httpd.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'httpd.c') diff --git a/httpd.c b/httpd.c index 3fafeb0..1145abd 100644 --- a/httpd.c +++ b/httpd.c @@ -153,7 +153,7 @@ void httpd_connection(FILE *f) d_char *body = NULL; int b_size = 0; char *ctype = NULL; - xs *headers = NULL; + xs *headers = xs_dict_new(); xs *q_path = NULL; xs *payload = NULL; xs *etag = NULL; @@ -232,9 +232,10 @@ void httpd_connection(FILE *f) #endif } - - /* let's go */ - headers = xs_dict_new(); + else + if (strcmp(method, "OPTIONS") == 0) { + status = 200; + } /* unattended? it's an error */ if (status == 0) { @@ -275,6 +276,9 @@ void httpd_connection(FILE *f) if (strcmp(method, "HEAD") == 0) body = xs_free(body); + headers = xs_dict_append(headers, "access-control-allow-origin", "*"); + headers = xs_dict_append(headers, "access-control-allow-headers", "*"); + xs_httpd_response(f, status, headers, body, b_size); fclose(f); -- cgit v1.2.3