From 5e9b59160845320c60f21e54d80e713fc5be30e0 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Thu, 29 May 2008 17:32:59 -0500 Subject: [PATCH] Fix file-responder breakage --- extra/http/server/static/static.factor | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/extra/http/server/static/static.factor b/extra/http/server/static/static.factor index 0e799fd3ad..8814004589 100755 --- a/extra/http/server/static/static.factor +++ b/extra/http/server/static/static.factor @@ -4,7 +4,7 @@ USING: calendar io io.files kernel math math.order math.parser http http.server namespaces parser sequences strings assocs hashtables debugger http.mime sorting html.elements html.templates.fhtml logging calendar.format accessors -io.encodings.binary fry xml.entities ; +io.encodings.binary fry xml.entities destructors ; IN: http.server.static ! special maps mime types to quots with effect ( path -- ) @@ -29,16 +29,14 @@ TUPLE: file-responder root hook special allow-listings ; swap >>root H{ } clone >>special ; +: (serve-static) ( path mime-type -- response ) + [ [ binary &dispose ] dip ] + [ drop file-info [ size>> ] [ modified>> ] bi ] 2bi + [ "content-length" set-header ] + [ "last-modified" set-header ] bi* ; + : ( root -- responder ) - [ - - swap [ - file-info - [ size>> "content-length" set-header ] - [ modified>> "last-modified" set-header ] bi - ] - [ '[ , binary output-stream get stream-copy ] >>body ] bi - ] ; + [ (serve-static) ] ; : serve-static ( filename mime-type -- response ) over modified-since?