summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--activitypub.c2
-rw-r--r--httpd.c11
2 files changed, 10 insertions, 3 deletions
diff --git a/activitypub.c b/activitypub.c
index fb790d5..7ac4c5f 100644
--- a/activitypub.c
+++ b/activitypub.c
@@ -880,7 +880,7 @@ int activitypub_get_handler(d_char *req, char *q_path,
xs *msg = NULL;
if (accept == NULL)
- return 400;
+ return 0;
if (xs_str_in(accept, "application/activity+json") == -1 &&
xs_str_in(accept, "application/ld+json") == -1)
diff --git a/httpd.c b/httpd.c
index d30d05b..4233057 100644
--- a/httpd.c
+++ b/httpd.c
@@ -7,6 +7,7 @@
#include "xs_json.h"
#include "xs_socket.h"
#include "xs_httpd.h"
+#include "xs_mime.h"
#include "snac.h"
@@ -30,7 +31,7 @@ int server_get_handler(d_char *req, char *q_path,
char *acpt = xs_dict_get(req, "accept");
if (acpt == NULL)
- return 400;
+ return 0;
/* is it the server root? */
if (*q_path == '\0') {
@@ -126,7 +127,7 @@ void httpd_connection(FILE *f)
if (xs_startswith(q_path, p))
q_path = xs_crop(q_path, strlen(p), 0);
- if (strcmp(method, "GET") == 0) {
+ if (strcmp(method, "GET") == 0 || strcmp(method, "HEAD") == 0) {
/* cascade through */
if (status == 0)
status = server_get_handler(req, q_path, &body, &b_size, &ctype);
@@ -181,6 +182,12 @@ void httpd_connection(FILE *f)
if (b_size == 0 && body != NULL)
b_size = strlen(body);
+ /* if it was a HEAD, no body will be sent */
+ if (strcmp(method, "HEAD") == 0) {
+ free(body);
+ body = NULL;
+ }
+
xs_httpd_response(f, status, headers, body, b_size);
fclose(f);