summaryrefslogtreecommitdiff
path: root/http.c
diff options
context:
space:
mode:
authorVincent Douillet <vincent@vdouillet.fr>2024-09-11 11:20:31 +0200
committerVincent Douillet <vincent@vdouillet.fr>2024-09-11 11:20:31 +0200
commit19e47daa9c1fb55f2cb9e639d5a6ef16b5bc4e88 (patch)
tree2b98ac0700a11cb142625d8355019c44b49c1850 /http.c
parent4e921ffa31fdca2425d326efda1c6d9ad190359a (diff)
url: fix encoding for use in http context
Diffstat (limited to 'http.c')
-rw-r--r--http.c8
1 files changed, 2 insertions, 6 deletions
diff --git a/http.c b/http.c
index 5bad1d8..4dbeff2 100644
--- a/http.c
+++ b/http.c
@@ -34,7 +34,7 @@
#include "http.h"
#include "mime.h"
-#include "str.h"
+#include "url.h"
bool
http_open_file(struct kreq * r, enum khttp code, const struct file * f)
@@ -49,13 +49,9 @@ http_open_file(struct kreq * r, enum khttp code, const struct file * f)
return false;
/* file name needs to be url encoded for special chars */
- filename = khttp_urlencode(filename);
- if (filename == NULL)
+ if ((filename = url_encode(filename)) == NULL)
return false;
- /* but for some reason, spaces should remain spaces... */
- str_replace(filename, '+', ' ');
-
khttp_head(r, kresps[KRESP_STATUS], "%s", khttps[code]);
khttp_head(r, kresps[KRESP_CONTENT_DISPOSITION],
"attachment;filename=\"%s\"", filename);