1 ! Copyright (C) 2008, 2010 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: math.parser http accessors kernel xml.syntax xml.writer
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-encoding
15 : <text-content> ( body -- response )
16 "text/plain" <content> ;
18 : <html-content> ( body -- response )
19 "text/html" <content> ;
21 : trivial-response-body ( code message -- )
30 : <trivial-response> ( code message -- response )
31 2dup [ trivial-response-body ] with-string-writer
36 : <304> ( -- response )
37 304 "Not modified" <trivial-response> ;
39 : <400> ( -- response )
40 400 "Bad request" <trivial-response> ;
42 : <403> ( -- response )
43 403 "Forbidden" <trivial-response> ;
45 : <404> ( -- response )
46 404 "Not found" <trivial-response> ;
48 : <405> ( -- response )
49 405 "Method Not Allowed" <trivial-response> ;