diff --git a/contrib/httpd/file-responder.factor b/contrib/httpd/file-responder.factor index 200d1dfe89..f877aae877 100644 --- a/contrib/httpd/file-responder.factor +++ b/contrib/httpd/file-responder.factor @@ -32,12 +32,12 @@ parser sequences strings ; "method" get "head" = [ drop ] [ - "request" get [ directory. ] simple-html-document + "request" get [ dup log-message directory. ] simple-html-document ] if ; : serve-directory ( filename -- ) - "/" ?tail [ - dup "/index.html" append dup exists? [ + "/" over tail? [ + dup "index.html" append dup exists? [ nip serve-file ] [ drop list-directory diff --git a/contrib/httpd/responder.factor b/contrib/httpd/responder.factor index c845994b6e..111998468c 100644 --- a/contrib/httpd/responder.factor +++ b/contrib/httpd/responder.factor @@ -62,10 +62,10 @@ SYMBOL: responders "Content-Length" swap hash dup [ string>number read query>hash ] when ; -: log-user-agent ( hash -- ) - "User-Agent" swap hash [ - [ "User Agent: " % ": " % % ] "" make log-message - ] when* ; +: log-headers ( hash -- ) + [ + drop { "User-Agent" "X-Forwarded-For" "Host" } member? + ] hash-subset [ ": " swap append3 log-message ] hash-each ; : prepare-url ( url -- url ) #! This is executed in the with-request namespace. @@ -75,7 +75,7 @@ SYMBOL: responders : prepare-header ( -- ) read-header dup "header" set - dup log-user-agent + dup log-headers read-post-request "response" set ; ! Responders are called in a new namespace with these