* do linebuffered/non-blocking reads from http requests
[citadel.git] / webcit / groupdav_options.c
index 1f476bc2cc423cdf0ecbf2e32a7827f8ec93ce7b..366f5ffe3ce580a6e3fe76766f252838f05c586e 100644 (file)
@@ -2,7 +2,6 @@
  * $Id$
  *
  * Handles DAV OPTIONS requests (experimental -- not required by GroupDAV)
- * \ingroup WebcitHttpServerGDav
  *
  */
 
@@ -13,7 +12,7 @@
 /*
  * The pathname is always going to be /groupdav/room_name/msg_num
  */
-void groupdav_options(char *dav_pathname) {
+void groupdav_options(const char *dav_pathname) {
        char dav_roomname[256];
        char dav_uid[256];
        long dav_msgnum = (-1);
@@ -29,12 +28,15 @@ void groupdav_options(char *dav_pathname) {
        /*
         * If the room name is blank, the client is doing a top-level OPTIONS.
         */
-       if (strlen(dav_roomname) == 0) {
-               wprintf("HTTP/1.1 200 OK\r\n");
+       if (IsEmptyStr(dav_roomname)) {
+               hprintf("HTTP/1.1 200 OK\r\n");
                groupdav_common_headers();
-               wprintf("Date: %s\r\n", datestring);
-               wprintf("Allow: OPTIONS, PROPFIND\r\n");
-               wprintf("\r\n");
+               hprintf("Date: %s\r\n", datestring);
+               hprintf("DAV: 1\r\n");
+               hprintf("Allow: OPTIONS, PROPFIND\r\n");
+               hprintf("\r\n");
+               begin_burst();
+               end_burst();
                return;
        }
 
@@ -42,54 +44,62 @@ void groupdav_options(char *dav_pathname) {
        if (strcasecmp(WC->wc_roomname, dav_roomname)) {
                gotoroom(dav_roomname);
        }
+
        if (strcasecmp(WC->wc_roomname, dav_roomname)) {
-               wprintf("HTTP/1.1 404 not found\r\n");
+               hprintf("HTTP/1.1 404 not found\r\n");
                groupdav_common_headers();
-               wprintf("Date: %s\r\n", datestring);
-               wprintf(
+               hprintf("Date: %s\r\n", datestring);
+               hprintf(
                        "Content-Type: text/plain\r\n"
                        "\r\n"
                        "There is no folder called \"%s\" on this server.\r\n",
                        dav_roomname
                );
+               begin_burst();
+               end_burst();
                return;
        }
 
        /* If dav_uid is non-empty, client is requesting an OPTIONS on
         * a specific item in the room.
         */
-       if (strlen(dav_uid) > 0) {
+       if (!IsEmptyStr(dav_uid)) {
 
                dav_msgnum = locate_message_by_uid(dav_uid);
                if (dav_msgnum < 0) {
-                       wprintf("HTTP/1.1 404 not found\r\n");
+                       hprintf("HTTP/1.1 404 not found\r\n");
                        groupdav_common_headers();
-                       wprintf(
+                       hprintf(
                                "Content-Type: text/plain\r\n"
                                "\r\n"
                                "Object \"%s\" was not found in the \"%s\" folder.\r\n",
                                dav_uid,
                                dav_roomname
                        );
-                       return;
+                       begin_burst();end_burst();return;
                }
 
-               wprintf("HTTP/1.1 200 OK\r\n");
+               hprintf("HTTP/1.1 200 OK\r\n");
                groupdav_common_headers();
-               wprintf("Date: %s\r\n", datestring);
-               wprintf("Allow: OPTIONS, PROPFIND, GET, PUT, DELETE\r\n");
-               wprintf("\r\n");
+               hprintf("Date: %s\r\n", datestring);
+               hprintf("DAV: 1\r\n");
+               hprintf("Allow: OPTIONS, PROPFIND, GET, PUT, DELETE\r\n");
+               hprintf("\r\n");
+               begin_burst();
+               end_burst();
                return;
        }
 
-
        /*
         * We got to this point, which means that the client is requesting
         * an OPTIONS on the room itself.
         */
-       wprintf("HTTP/1.1 200 OK\r\n");
+       hprintf("HTTP/1.1 200 OK\r\n");
        groupdav_common_headers();
-       wprintf("Date: %s\r\n", datestring);
-       wprintf("Allow: OPTIONS, PROPFIND, GET, PUT\r\n");
-       wprintf("\r\n");
+       hprintf("Date: %s\r\n", datestring);
+       hprintf("DAV: 1\r\n");
+       hprintf("Allow: OPTIONS, PROPFIND, GET, PUT\r\n");
+       hprintf("\r\n");
+       begin_burst();
+       end_burst();
 }