httpserver/static.spl: add individual settings for bufsize and client-cache
This commit is contained in:
parent
210eaade3a
commit
e72baba154
1 changed files with 11 additions and 3 deletions
|
@ -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<net:http:server:bufsize> this:write-ok:write-content-type<type>:write-body:finish;
|
||||
filepath StreamTypes:file:create<0>:read-to-end<this:get-bufsize> this:write-ok:write-content-type<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<net:http:server:bufsize> dup this:server:cached-files:set;<filepath>
|
||||
pop filepath StreamTypes:file:create<0>:read-to-end<this:get-bufsize> dup this:server:cached-files:set;<filepath>
|
||||
}
|
||||
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<type>:write-body:finish;
|
||||
}
|
||||
this
|
||||
|
|
Loading…
Add table
Reference in a new issue