chiark / gitweb /
cgi: more graceful error handling in absence of server
[disorder] / server / cgimain.c
index 5acf9ea5208494e9e20f3b281d7d609d7286490b..53f7a9bac6189e37df639ed1f78594d3d41916c5 100644 (file)
@@ -33,7 +33,6 @@
 #include "client.h"
 #include "sink.h"
 #include "cgi.h"
-#include "dcgi.h"
 #include "mem.h"
 #include "log.h"
 #include "configuration.h"
@@ -41,6 +40,7 @@
 #include "api-client.h"
 #include "mime.h"
 #include "printf.h"
+#include "dcgi.h"
 
 /** @brief Infer the base URL for the web interface if it's not set
  *
@@ -111,11 +111,7 @@ int main(int argc, char **argv) {
        login_cookie = cd.cookies[n].value;
     }
   }
-  /* Log in with the cookie if possible otherwise as guest */
-  if(disorder_connect_cookie(g.client, login_cookie)) {
-    disorder_cgi_error(&output, &s, "connect");
-    return 0;
-  }
+  disorder_cgi_login(&s, &output);
   /* TODO RFC 3875 s8.2 recommendations e.g. concerning PATH_INFO */
   disorder_cgi(&output, &s);
   if(fclose(stdout) < 0) fatal(errno, "error closing stdout");