diff options
Diffstat (limited to 'http.c')
-rw-r--r-- | http.c | 13 |
1 files changed, 10 insertions, 3 deletions
@@ -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; |