(declare (block) (standard-bindings) (extended-bindings))
(begin
  (declare (not safe))
  (define std/net/httpd/file#open-flags
    (if std/os/fcntl#O_NOATIME
        (fxior std/os/fcntl#O_RDONLY std/os/fcntl#O_NOATIME)
        std/os/fcntl#O_RDONLY))
  (define std/net/httpd/file#http-response-file
    (lambda (_res454_ _headers455_ _path456_)
      (let ((_file458_
             (std/os/fdio#open__0 _path456_ std/net/httpd/file#open-flags)))
        (with-unwind-protect
         (lambda ()
           (std/net/httpd/file#http-response-write-file
            _res454_
            _headers455_
            _file458_))
         (lambda () (close-port _file458_))))))
  (define std/net/httpd/file#http-response-write-file
    (lambda (_res443_ _headers444_ _file445_)
      (let ((_buf447_ (std/net/httpd/file#get-file-buffer)))
        (std/net/httpd/handler#http-response-begin _res443_ '200 _headers444_)
        (let _lp449_ ()
          (let ((_rd452_ (std/os/fdio#fdread__0 _file445_ _buf447_)))
            (if (not _rd452_)
                (begin
                  (std/event#wait__0 (std/os/fd#fd-io-in _file445_))
                  (_lp449_))
                (if (fx= _rd452_ '0)
                    (begin
                      (std/net/httpd/file#put-file-buffer _buf447_)
                      (std/net/httpd/handler#http-response-end _res443_))
                    (begin
                      (std/net/httpd/handler#http-response-chunk__%
                       _res443_
                       _buf447_
                       '0
                       _rd452_)
                      (_lp449_)))))))))
  (define std/net/httpd/file#buffer-cache '())
  (define std/net/httpd/file#get-file-buffer
    (lambda ()
      (declare (not interrupts-enabled))
      (if (##pair? std/net/httpd/file#buffer-cache)
          (let ((_buf441_ (##car std/net/httpd/file#buffer-cache)))
            (set! std/net/httpd/file#buffer-cache
                  (##cdr std/net/httpd/file#buffer-cache))
            _buf441_)
          (make-u8vector '8192))))
  (define std/net/httpd/file#put-file-buffer
    (lambda (_buf436_)
      (declare (not interrupts-enabled))
      (set! std/net/httpd/file#buffer-cache
            (##cons _buf436_ std/net/httpd/file#buffer-cache)))))
