mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-22 05:15:04 +00:00
Added support for HEAD methods.
Mastodon uses them when it founds an attachment.
This commit is contained in:
parent
d9a15b8af7
commit
395f80bdc4
2 changed files with 10 additions and 3 deletions
|
@ -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)
|
||||
|
|
11
httpd.c
11
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);
|
||||
|
|
Loading…
Reference in a new issue