X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=webcit-ng%2Frequest.c;h=baffe6dbc84c6bd5389247dad66bd1beb6c1e6aa;hb=4e8a0162220ff9389ca378d39344abda66987539;hp=186b2ac66065c9200f44893e69af15f33a343b63;hpb=1de34ae393d0f8bf9c1fb9131765ee50449f4806;p=citadel.git diff --git a/webcit-ng/request.c b/webcit-ng/request.c index 186b2ac66..baffe6dbc 100644 --- a/webcit-ng/request.c +++ b/webcit-ng/request.c @@ -5,7 +5,7 @@ * and pass control back down to the HTTP layer to output the response back to * the client. * - * Copyright (c) 1996-2016 by the citadel.org team + * Copyright (c) 1996-2018 by the citadel.org team * * This program is open source software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 3. @@ -92,7 +92,8 @@ void perform_request(struct http_transaction *h) // This is implemented as a series of strncasecmp() calls rather than a // lookup table in order to make the code more readable. - if (IsEmptyStr(h->uri)) { // Sanity check + if (IsEmptyStr(h->uri)) + { // Sanity check do_404(h); return; } @@ -101,7 +102,8 @@ void perform_request(struct http_transaction *h) // with the /ctdl/ prefix. // Root (/) ... - if ( (!strcmp(h->uri, "/")) && (!strcasecmp(h->method, "GET")) ) { + if ( (!strcmp(h->uri, "/")) && (!strcasecmp(h->method, "GET")) ) + { http_redirect(h, "/ctdl/s/index.html"); return; } @@ -111,17 +113,20 @@ void perform_request(struct http_transaction *h) // Everything below this line is strictly REST URI patterns. - if (strncasecmp(h->uri, HKEY("/ctdl/"))) { // Reject non-REST + if (strncasecmp(h->uri, HKEY("/ctdl/"))) + { // Reject non-REST do_404(h); return; } - if (!strncasecmp(h->uri, HKEY("/ctdl/s/"))) { // Static content + if (!strncasecmp(h->uri, HKEY("/ctdl/s/"))) + { // Static content output_static(h); return; } - if (h->uri[7] != '/') { + if (h->uri[7] != '/') + { do_404(h); return; } @@ -131,14 +136,16 @@ void perform_request(struct http_transaction *h) // 2. Requires a connection to a Citadel server. c = connect_to_citadel(h); - if (c == NULL) { + if (c == NULL) + { do_502(h); return; } // WebDAV methods like OPTIONS and PROPFIND *require* a logged-in session, // even if the Citadel server allows anonymous access. - if (IsEmptyStr(c->auth)) { + if (IsEmptyStr(c->auth)) + { if ( (!strcasecmp(h->method, "OPTIONS")) || (!strcasecmp(h->method, "PROPFIND")) || (!strcasecmp(h->method, "REPORT")) @@ -152,7 +159,8 @@ void perform_request(struct http_transaction *h) // Break down the URI by path and send the request to the appropriate part of the program. // - switch(h->uri[6]) { + switch(h->uri[6]) + { case 'a': // /ctdl/a/ == RESTful path to admin functions ctdl_a(h, c); break; @@ -170,7 +178,8 @@ void perform_request(struct http_transaction *h) } // Are we in an authenticated session? If so, set a cookie so we stay logged in. - if (!IsEmptyStr(c->auth)) { + if (!IsEmptyStr(c->auth)) + { char koekje[AUTH_MAX]; char *exp = http_datestring(time(NULL) + (86400 * 30)); snprintf(koekje, AUTH_MAX, "wcauth=%s; path=/ctdl/; Expires=%s", c->auth, exp);