openwrt / uhttpd

[MIRROR] Tiny HTTP server
https://git.openwrt.org/?p=project/uhttpd.git;
11 stars 7 forks source link

main/file: add support for custom headers to file serving #13

Open wryun opened 4 days ago

wryun commented 4 days ago

This allows us to set 'Cache-Control: no-cache', which makes it possible to develop LuCI JS without resorting to disabling the cache in the browser dev tools.

See: https://github.com/openwrt/luci/issues/7059

If this was merged, the follow up to OpenWrt would look something like:

diff --git a/package/network/services/uhttpd/files/uhttpd.init b/package/network/services/uhttpd/files/uhttpd.init
index 89ca0c6c1d..3589024bbd 100755
--- a/package/network/services/uhttpd/files/uhttpd.init
+++ b/package/network/services/uhttpd/files/uhttpd.init
@@ -103,6 +103,10 @@ append_ucode_prefix() {
        fi
 }

+append_extra_header() {
+       procd_append_param command -z "$1"
+}
+
 start_instance()
 {
        UHTTPD_CERT=""
@@ -190,6 +194,8 @@ start_instance()
                procd_append_param command -I "$path"
        done

+       config_list_foreach "$cfg" extra_header append_extra_header
+
        config_get https "$cfg" listen_https
        config_get UHTTPD_KEY  "$cfg" key  /etc/uhttpd.key
        config_get UHTTPD_CERT "$cfg" cert /etc/uhttpd.crt