diff options
author | Louis Brauer <louis@openbooking.ch> | 2024-05-26 21:45:41 +0200 |
---|---|---|
committer | Louis Brauer <louis@openbooking.ch> | 2024-05-26 21:45:41 +0200 |
commit | 0e21d35e802bf859aa14bce688cd9544458e9e9c (patch) | |
tree | 55861603d4f702d56edafe24aa1019484b714fbc /httpd.c | |
parent | 9749a65007e88a6a7d8d98b6f6b98a1a47b46bdb (diff) |
Use enum instead of numeric status codes for HTTP statuses
Diffstat (limited to 'httpd.c')
-rw-r--r-- | httpd.c | 26 |
1 files changed, 13 insertions, 13 deletions
@@ -217,17 +217,17 @@ int server_get_handler(xs_dict *req, const char *q_path, *body = greeting_html(); if (*body) - status = 200; + status = HTTP_STATUS_OK; } else if (strcmp(q_path, "/susie.png") == 0 || strcmp(q_path, "/favicon.ico") == 0 ) { - status = 200; + status = HTTP_STATUS_OK; *body = xs_base64_dec(default_avatar_base64(), b_size); *ctype = "image/png"; } else if (strcmp(q_path, "/.well-known/nodeinfo") == 0) { - status = 200; + status = HTTP_STATUS_OK; *ctype = "application/json; charset=utf-8"; *body = xs_fmt("{\"links\":[" "{\"rel\":\"http:/" "/nodeinfo.diaspora.software/ns/schema/2.0\"," @@ -236,7 +236,7 @@ int server_get_handler(xs_dict *req, const char *q_path, } else if (strcmp(q_path, "/.well-known/host-meta") == 0) { - status = 200; + status = HTTP_STATUS_OK; *ctype = "application/xrd+xml"; *body = xs_fmt("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" "<XRD>" @@ -245,13 +245,13 @@ int server_get_handler(xs_dict *req, const char *q_path, } else if (strcmp(q_path, "/nodeinfo_2_0") == 0) { - status = 200; + status = HTTP_STATUS_OK; *ctype = "application/json; charset=utf-8"; *body = nodeinfo_2_0(); } else if (strcmp(q_path, "/robots.txt") == 0) { - status = 200; + status = HTTP_STATUS_OK; *ctype = "text/plain"; *body = xs_str_new("User-agent: *\n" "Disallow: /\n"); @@ -363,7 +363,7 @@ void httpd_connection(FILE *f) } else if (strcmp(method, "OPTIONS") == 0) { - status = 200; + status = HTTP_STATUS_OK; } else if (strcmp(method, "DELETE") == 0) { @@ -378,22 +378,22 @@ void httpd_connection(FILE *f) if (status == 0) { srv_archive_error("unattended_method", "unattended method", req, payload); srv_debug(1, xs_fmt("httpd_connection unattended %s %s", method, q_path)); - status = 404; + status = HTTP_STATUS_NOT_FOUND; } - if (status == 403) + if (status == HTTP_STATUS_FORBIDDEN) body = xs_str_new("<h1>403 Forbidden</h1>"); - if (status == 404) + if (status == HTTP_STATUS_NOT_FOUND) body = xs_str_new("<h1>404 Not Found</h1>"); - if (status == 400 && body != NULL) + if (status == HTTP_STATUS_BAD_REQUEST && body != NULL) body = xs_str_new("<h1>400 Bad Request</h1>"); - if (status == 303) + if (status == HTTP_STATUS_SEE_OTHER) headers = xs_dict_append(headers, "location", body); - if (status == 401) { + if (status == HTTP_STATUS_UNAUTHORIZED) { xs *www_auth = xs_fmt("Basic realm=\"@%s@%s snac login\"", body, xs_dict_get(srv_config, "host")); |