From 8ec2730db7031a05d63f59ba7080f13da9677d2d Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Wed, 20 Jul 2022 02:04:07 +0530 Subject: web: server: Respond to a static file request with a bytevector. If the response to a static file request is returned as a procedure, (web server) tries to interpret the response as text. This results in encoding errors with binary files. Fixing this is not worth the trouble since (tissue web server) is anyway not meant to serve large static files. Large static files should be served using a more capable server such as nginx. * tissue/web/server.scm (handler): Return response to a static file request as a bytevector, instead of as a procedure. --- tissue/web/server.scm | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/tissue/web/server.scm b/tissue/web/server.scm index 25ece4b..8f967b9 100644 --- a/tissue/web/server.scm +++ b/tissue/web/server.scm @@ -333,16 +333,8 @@ STATE-DIRECTORY." (values `((content-type . ,(or (assoc-ref %mime-types (string-remove-prefix "." (file-name-extension file-path))) '(application/octet-stream)))) - ;; Return a procedure so that the file can be - ;; read out a little at a time instead of having - ;; to load it whole into memory. - (lambda (out) - (call-with-input-file file-path - (lambda (in) - (port-transduce (tmap (cut put-bytevector out <>)) - (const #t) - get-bytevector-some - in))))))) + (call-with-input-file file-path + get-bytevector-all)))) ;; Not found (else (values (build-response #:code 404) -- cgit v1.2.3