httpserver/static.spl: write body as bytes when serving 'file'
This commit is contained in:
parent
c9463c6938
commit
4749c142fa
1 changed files with 4 additions and 3 deletions
|
@ -1,4 +1,5 @@
|
|||
"base.spl" import
|
||||
"../stream.spl" import
|
||||
|
||||
"_static_ext_server" net:http:server:register
|
||||
"_static_ext_Request" net:http:server:register
|
||||
|
@ -15,16 +16,16 @@ construct net:http:server:_static_ext_Request {
|
|||
;
|
||||
serve-file { this | with filepath path type this ;
|
||||
this:path path eq if {
|
||||
filepath read-file this:write-ok:write-content-type<type>:write-str-body:finish;
|
||||
filepath StreamTypes:file:create<0>:read-to-end<1024> 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 read-file dup this:server:cached-files:set;<filepath>
|
||||
pop filepath StreamTypes:file:create<0>:read-to-end<1024> dup this:server:cached-files:set;<filepath>
|
||||
}
|
||||
this:write-ok:write-content-type<type>:write-str-body:finish;
|
||||
this:write-ok:write-content-type<type>:write-body:finish;
|
||||
}
|
||||
this
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue