1 ! Copyright (C) 2008 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: html.elements math.parser http accessors kernel
4 io io.streams.string io.encodings.utf8 ;
5 IN: http.server.responses
7 : <content> ( body content-type -- response )
10 "Document follows" >>message
11 utf8 >>content-charset
15 : trivial-response-body ( code message -- )
18 <h1> [ number>string write bl ] [ write ] bi* </h1>
22 : <trivial-response> ( code message -- response )
23 2dup [ trivial-response-body ] with-string-writer
28 : <304> ( -- response )
29 304 "Not modified" <trivial-response> ;
31 : <403> ( -- response )
32 403 "Forbidden" <trivial-response> ;
34 : <400> ( -- response )
35 400 "Bad request" <trivial-response> ;
37 : <404> ( -- response )
38 404 "Not found" <trivial-response> ;