Software /
code /
prosody
Comparison
net/http/files.lua @ 13445:360e05f33835 0.12
net.http.files: Validate argument to setup function
Fixes error in #1765 by throwing an error earlier
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Tue, 27 Feb 2024 17:14:16 +0100 |
parent | 11658:36942fa001b4 |
child | 13446:dba7073f1452 |
comparison
equal
deleted
inserted
replaced
13408:d7857ef7843a | 13445:360e05f33835 |
---|---|
56 end | 56 end |
57 local mime_map = opts.mime_map or { html = "text/html" }; | 57 local mime_map = opts.mime_map or { html = "text/html" }; |
58 local cache = new_cache(opts.cache_size or 256); | 58 local cache = new_cache(opts.cache_size or 256); |
59 local cache_max_file_size = tonumber(opts.cache_max_file_size) or 1024 | 59 local cache_max_file_size = tonumber(opts.cache_max_file_size) or 1024 |
60 -- luacheck: ignore 431 | 60 -- luacheck: ignore 431 |
61 local base_path = opts.path; | 61 local base_path = assert(opts.path, "invalid argument to net.http.files.path(), missing required 'path'"); |
62 local dir_indices = opts.index_files or { "index.html", "index.htm" }; | 62 local dir_indices = opts.index_files or { "index.html", "index.htm" }; |
63 local directory_index = opts.directory_index; | 63 local directory_index = opts.directory_index; |
64 local function serve_file(event, path) | 64 local function serve_file(event, path) |
65 local request, response = event.request, event.response; | 65 local request, response = event.request, event.response; |
66 local sanitized_path = sanitize_path(path); | 66 local sanitized_path = sanitize_path(path); |