summaryrefslogtreecommitdiff
path: root/http.c
diff options
context:
space:
mode:
authorVincent Douillet <vincent@vdouillet.fr>2024-01-23 09:22:00 +0100
committerVincent Douillet <vincent@vdouillet.fr>2024-02-08 09:27:54 +0100
commit42f538cc66546997a166dbe67e489c9afabbb908 (patch)
tree718bb6b7161892c4b964499c1818c6d7bf0bd6a6 /http.c
parent760031b4a74d70bdeaab4ce9aedfe772acd05bd3 (diff)
download files
Diffstat (limited to 'http.c')
-rw-r--r--http.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/http.c b/http.c
index 4df7d93..b79b361 100644
--- a/http.c
+++ b/http.c
@@ -33,6 +33,18 @@
#include <stdlib.h>
#include "http.h"
+#include "mime.h"
+
+void
+http_open_file(struct kreq * r, enum khttp code, struct file * f)
+{
+ khttp_head(r, kresps[KRESP_STATUS], "%s", khttps[code]);
+ khttp_head(r, kresps[KRESP_CONTENT_DISPOSITION],
+ "attachment;filename=\"%s\"", f->name);
+ khttp_head(r, kresps[KRESP_CONTENT_TYPE], "%s", mime_str(f->mime));
+ khttp_head(r, kresps[KRESP_CONTENT_LENGTH], "%zu", f->size);
+ khttp_body_compress(r, 0); /* file is not compressed */
+}
void
http_open(struct kreq * r, enum khttp code, enum kmime mime)