Changeset 5522 in project


Ignore:
Timestamp:
08/19/07 21:42:11 (12 years ago)
Author:
sjamaan
Message:

Implement sendfile for static files

Location:
spiffy/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • spiffy/trunk/spiffy-base.scm

    r5516 r5522  
    3636;; * Think about ways to improve testing, maybe by hacking http-client (notably, sending requests without Host: line)
    3737
    38 (require-extension utils regex posix srfi-1 srfi-13 http-server)
     38(require-extension utils regex posix srfi-1 srfi-13 http-server sendfile)
    3939
    4040(declare
     
    234234                  (let ((buf (car (file-read fd size))))
    235235                    (cache-write fn buf)
    236                     (display buf) )
    237                   (let ([buffer (make-string rbs)])
    238                     (let loop ([n size])
    239                       (unless (zero? n)
    240                         (match (file-read fd (min n rbs) buffer)
    241                           [(_ k)
    242                            (display (if (< k rbs) (substring buffer 0 k) buffer))
    243                            (loop (- n k)) ] ) ) ) ) )
    244               (file-close fd) ) ) ) ) ) )
     236                    (display buf))
     237                  (sendfile:sendfile fd (current-output-port))) ;; XXX TODO: Benchmark this! Need to know if it's really faster than a loop
     238              (file-close fd)))))))
    245239
    246240(define (chop-slash fn)
  • spiffy/trunk/spiffy.meta

    r5319 r5522  
    55 (synopsis "Spiffy the web-server")
    66 (doc-from-wiki)
    7  (needs regex-case http)
     7 (needs regex-case http sendfile)
    88 (category web)
    99 (license "BSD")
Note: See TracChangeset for help on using the changeset viewer.