(define (send-static-file filename) (condition-case (let* ((path (make-pathname (root-path) filename)) (h (request-headers (current-request))) (size (file-size path)) (last-modified (file-modification-time path)) (etag (cons 'strong (conc size "-" last-modified))) (unmodified (or (and-let* ((t (header-values 'if-none-match h))) (etag-matches? etag t)) (and-let* ((t (header-value 'if-modified-since h))) (<= last-modified (utc-time->seconds t)))))) (parameterize ((current-response (if unmodified (update-response (current-response) status: 'not-modified) (current-response)))) (with-headers `((last-modified #(,(seconds->utc-time last-modified))) (etag ,etag) (content-length ,(if unmodified 0 size)) (content-type ,(file-extension->mime-type (pathname-extension filename)))) (lambda () (write-logged-response) (when ((response-has-message-body-for-request?) (current-response) (current-request)) (with-output-to-port (response-port (current-response)) (lambda () ;workaround (print(read-all path)) ))))))) ((exn i/o file) (send-status 'forbidden))))