changeset 16:29033b4fe558

pasterd: use default values and fix Content-Length
author David Demelier <markand@malikania.fr>
date Thu, 06 Feb 2020 13:25:22 +0100
parents 4e80c9233b8e
children 09d2f54562ec
files http.c pasterd.c
diffstat 2 files changed, 10 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/http.c	Thu Feb 06 13:25:03 2020 +0100
+++ b/http.c	Thu Feb 06 13:25:22 2020 +0100
@@ -797,7 +797,7 @@
 	else {
 		khttp_head(req, kresps[KRESP_STATUS], "%s", khttps[KHTTP_200]);
 		khttp_head(req, kresps[KRESP_CONTENT_TYPE], "%s", kmimetypes[req->mime]);
-		khttp_head(req, kresps[KRESP_CONTENT_TYPE],
+		khttp_head(req, kresps[KRESP_CONTENT_LENGTH],
 		    "%llu", (unsigned long long)(st.st_size));
 		khttp_body(req);
 		khttp_template(req, NULL, path);
--- a/pasterd.c	Thu Feb 06 13:25:03 2020 +0100
+++ b/pasterd.c	Thu Feb 06 13:25:22 2020 +0100
@@ -29,6 +29,13 @@
 #include "util.h"
 
 static void
+defaults(void)
+{
+	snprintf(config.databasepath, sizeof (config.databasepath),
+	    "%s", VARDIR "/paster/paster.db");
+}
+
+static void
 init(void)
 {
 	srand(time(NULL));
@@ -61,6 +68,8 @@
 	int opt;
 	void (*run)(void) = &(http_cgi_run);
 
+	defaults();
+
 	/* Seek environment variables before options. */
 	if ((value = getenv("PASTERD_DATABASE_PATH")))
 		snprintf(config.databasepath, sizeof (config.databasepath), "%s", value);