Changeset 12024 in project


Ignore:
Timestamp:
09/28/08 18:44:19 (12 years ago)
Author:
sjamaan
Message:

Make filename handling work the same way directory handling works

File:
1 edited

Legend:

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

    r12023 r12024  
    101101(define request-restarter (make-parameter #f))
    102102
     103;; A simple utility procedure to render a status code with message
    103104(define (send-status code reason #!optional text)
    104105  (parameterize ((current-response (update-response (current-response)
     
    124125
    125126(define (send-static-file filename)
    126   (with-headers `((content-length ,(file-size filename)))
    127     (lambda ()
    128       (write-response (current-response))
    129       (let ([fd (file-open filename (+ open/binary open/rdonly))])
    130               (handle-exceptions exn (begin
    131                                        (file-close fd)
    132                                        (signal exn))
    133                 (sendfile fd (response-port (current-response))))
    134               (file-close fd)))))
     127  (let ((path (make-pathname (root-path) filename)))
     128    (with-headers `((content-length ,(file-size path)))
     129      (lambda ()
     130        (write-response (current-response))
     131        (let ([fd (file-open path (+ open/binary open/rdonly))])
     132          (handle-exceptions exn (begin
     133                                   (file-close fd)
     134                                   (signal exn))
     135                             (sendfile fd (response-port (current-response))))
     136          (file-close fd))))))
    135137
    136138(define (extension->mime-type ext)
     
    176178                             (cdr remaining-path)))))
    177179     ((file-exists? path)
    178       ((handle-file) path))
     180      ((handle-file) current-path))
    179181     (else ((handle-not-found))))))
    180182
Note: See TracChangeset for help on using the changeset viewer.