From e72baba154994ae7a5fa14acdc3c8f4848a655de Mon Sep 17 00:00:00 2001 From: TudbuT Date: Mon, 14 Oct 2024 17:10:46 +0200 Subject: [PATCH] httpserver/static.spl: add individual settings for bufsize and client-cache --- spl/httpserver/static.spl | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/spl/httpserver/static.spl b/spl/httpserver/static.spl index 0d6f1cf..0aaef4c 100644 --- a/spl/httpserver/static.spl +++ b/spl/httpserver/static.spl @@ -8,6 +8,8 @@ 1024 net:http:server:=bufsize construct net:http:server:_static_ext_server { + bufsize + client-cache cached-files ; get-cached-files { cached-files | with this ; @@ -17,18 +19,24 @@ construct net:http:server:_static_ext_server { construct net:http:server:_static_ext_Request { ; + get-bufsize { bufsize | with this ; + this:bufsize net:http:server:bufsize or + } + get-client-cache { client-cache | with this ; + this:client-cache net:http:server:client-cache or + } serve-file { this | with filepath path type this ; this:path path eq if { - filepath StreamTypes:file:create<0>:read-to-end this:write-ok:write-content-type:write-body:finish; + filepath StreamTypes:file:create<0>:read-to-end this:write-ok:write-content-type:write-body:finish; } this } serve-file-cached { this | with filepath path type this ; this:path path eq if { filepath this:server:get-cached-files:get dup not if { - pop filepath StreamTypes:file:create<0>:read-to-end dup this:server:cached-files:set; + pop filepath StreamTypes:file:create<0>:read-to-end dup this:server:cached-files:set; } - def cache net:http:server:client-cache =cache + def cache this:get-client-cache =cache this:write-ok cache if { :write-header<"Cache-Control" "public, max-age=" cache _str concat> } :write-content-type:write-body:finish; } this