fix mkcol not responding with correct status code in some cases

Sun, 25 Sep 2022 15:40:27 +0200

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Sun, 25 Sep 2022 15:40:27 +0200
changeset 395
224c4e858125
parent 394
4d2a1df73e18
child 396
77d81f2bb9f7

fix mkcol not responding with correct status code in some cases

src/server/webdav/webdav.c file | annotate | diff | comparison | revisions
--- a/src/server/webdav/webdav.c	Sun Sep 25 15:23:08 2022 +0200
+++ b/src/server/webdav/webdav.c	Sun Sep 25 15:40:27 2022 +0200
@@ -540,17 +540,20 @@
         protocol_start_response(sn, rq);
         ret = REQ_PROCEED;
     } else {
-        int status_code = 500;
-        if(op->vfs->vfs_errno == EEXIST) {
-            // 405 (Method Not Allowed) - MKCOL can only be executed on an unmapped URL.
-            status_code = 405;
-        } else if(op->vfs->vfs_errno == ENOENT) {
-            // 409 (Conflict) - A collection cannot be made at the Request-URI until
-            // one or more intermediate collections have been created.  The server
-            // MUST NOT create those intermediate collections automatically.
-            status_code = 409;
+        if(rq->status_num <= 0) {
+            int status_code = 500;
+            if(op->vfs->vfs_errno == EEXIST) {
+                // 405 (Method Not Allowed) - MKCOL can only be executed on an unmapped URL.
+                status_code = 405;
+            } else if(op->vfs->vfs_errno == ENOENT) {
+                // 409 (Conflict) - A collection cannot be made at the Request-URI until
+                // one or more intermediate collections have been created.  The server
+                // MUST NOT create those intermediate collections automatically.
+                status_code = 409;
+            }
+            protocol_status(sn, rq, status_code, NULL);
         }
-        protocol_status(sn, rq, status_code, NULL);
+        
     }
     
     return ret;

mercurial