! Copyright (C) 2008, 2010 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: math.parser http accessors kernel xml.syntax xml.writer io io.streams.string io.encodings.utf8 ; IN: http.server.responses : ( body content-type -- response ) 200 >>code "Document follows" >>message utf8 >>content-encoding swap >>content-type swap >>body ; : ( body -- response ) "text/plain" ; : ( body -- response ) "text/html" ; : trivial-response-body ( code message -- )

<-> <->

XML> write-xml ; : ( code message -- response ) 2dup [ trivial-response-body ] with-string-writer swap >>message swap >>code ; : <304> ( -- response ) 304 "Not modified" ; : <400> ( -- response ) 400 "Bad request" ; : <403> ( -- response ) 403 "Forbidden" ; : <404> ( -- response ) 404 "Not found" ; : <405> ( -- response ) 405 "Method Not Allowed" ;