summaryrefslogtreecommitdiff
path: root/http.c
diff options
context:
space:
mode:
authorVincent Douillet <vincent@vdouillet.fr>2024-09-05 12:58:22 +0200
committerVincent Douillet <vincent@vdouillet.fr>2024-09-06 12:22:20 +0200
commit35a145fd161fb4d4f19aa9820b50438695b94414 (patch)
tree00e9f341d5b7e0a6874efbe9fafc0500cf13cd2d /http.c
parent9b8d38ab209c6e7e747d6d420f1b105fe858c7eb (diff)
browse: add upload button
Diffstat (limited to 'http.c')
-rw-r--r--http.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/http.c b/http.c
index ef8d90c..5bad1d8 100644
--- a/http.c
+++ b/http.c
@@ -37,12 +37,19 @@
#include "str.h"
bool
-http_open_file(struct kreq * r, enum khttp code, struct file * f)
+http_open_file(struct kreq * r, enum khttp code, const struct file * f)
{
char *filename;
+ if (f == NULL || f->path == NULL)
+ return false;
+
+ filename = file_get_basename(f);
+ if (filename == NULL)
+ return false;
+
/* file name needs to be url encoded for special chars */
- filename = khttp_urlencode(f->name);
+ filename = khttp_urlencode(filename);
if (filename == NULL)
return false;
@@ -69,7 +76,7 @@ http_open(struct kreq * r, enum khttp code, enum kmime mime)
}
void
-http_exit(struct kreq * r, enum khttp code, char *content,...)
+http_exit(const struct kreq * r, enum khttp code, const char *content,...)
{
va_list args;