]> code.citadel.org Git - citadel.git/blobdiff - webcit-ng/server/request.c
Skeleton code for filters.
[citadel.git] / webcit-ng / server / request.c
index 605520e68f8debb0d8d961c9f24feb5d709538ac..bd1b3253888e1f8d96968c41d842daf51ea05915 100644 (file)
@@ -4,10 +4,9 @@
 // and pass control back down to the HTTP layer to output the response back to
 // the client.
 //
-// Copyright (c) 1996-2022 by the citadel.org team
+// Copyright (c) 1996-2023 by the citadel.org team
 //
-// This program is open source software.  Use, duplication, or
-// disclosure are subject to the GNU General Public License v3.
+// This program is open source software.  Use, duplication, or disclosure is subject to the GNU General Public License v3.
 
 #include "webcit.h"
 
@@ -22,6 +21,13 @@ void do_404(struct http_transaction *h) {
 }
 
 
+// Method not allowed
+void do_405(struct http_transaction *h) {
+       h->response_code = 412;
+       h->response_string = strdup("METHOD NOT ALLOWED");
+}
+
+
 // Precondition failed (such as if-match)
 void do_412(struct http_transaction *h) {
        h->response_code = 412;
@@ -132,10 +138,12 @@ void perform_request(struct http_transaction *h) {
        // WebDAV methods like OPTIONS and PROPFIND *require* a logged-in session,
        // even if the Citadel server allows anonymous access.
        if (IsEmptyStr(c->auth)) {
-               if (    (!strcasecmp(h->method, "OPTIONS"))
+               if (       (!strcasecmp(h->method, "OPTIONS"))
                        || (!strcasecmp(h->method, "PROPFIND"))
                        || (!strcasecmp(h->method, "REPORT"))
                        || (!strcasecmp(h->method, "DELETE"))
+                       || (!strcasecmp(h->method, "MOVE"))
+                       || (!strcasecmp(h->method, "COPY"))
                ) {
                        request_http_authenticate(h);
                        disconnect_from_citadel(c);
@@ -160,6 +168,9 @@ void perform_request(struct http_transaction *h) {
        case 'u':               // /ctdl/u/ == RESTful path to users
                ctdl_u(h, c);
                break;
+       case 'p':               // /ctdl/p/ == RESTful path to upload functions
+               ctdl_p(h, c);
+               break;
        default:
                do_404(h);
        }