Changeset 18694 in project


Ignore:
Timestamp:
07/03/10 18:04:13 (11 years ago)
Author:
sjamaan
Message:

spiffy: Simplify send-static-file by using call-with-input-file instead of hand-rolled convoluted code based on file-open and dynamic-wind

Location:
release/4/spiffy/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • release/4/spiffy/trunk/spiffy.meta

    r18066 r18694  
    88 (license "BSD")
    99 (doc-from-wiki)
    10  (depends openssl (intarweb 0.3) uri-common defstruct (sendfile 1.6.2) matchable)
     10 (depends openssl (intarweb 0.3) uri-common defstruct (sendfile 1.7) matchable)
    1111 (test-depends test)
    1212 (files "spiffy.scm" "spiffy.setup" "spiffy.html"
  • release/4/spiffy/trunk/spiffy.scm

    r18689 r18694  
    299299                                                 reason: "Not modified")))
    300300                  (write-logged-response))
    301                 (let ((fd #f))
     301                (begin
    302302                  (write-logged-response)
    303303                  (unless (eq? 'HEAD (request-method (current-request)))
    304                    (dynamic-wind
    305                        (lambda ()
    306                          (set! fd (file-open path (+ open/binary open/rdonly))))
    307                        (lambda ()
    308                          (let ((port (response-port (current-response))))
    309                            (sendfile fd port)))
    310                        (lambda ()
    311                          (file-close fd) (set! fd #f)))))))))
     304                    (call-with-input-file path
     305                      (lambda (f)
     306                        (sendfile f (response-port (current-response)))))))))))
    312307    ((exn i/o file) (send-status 403 "Forbidden"))))
    313308
Note: See TracChangeset for help on using the changeset viewer.