class

WebRes

abstract class WebRes : Obj

WebRes encapsulates a response to a web request.

See pod doc

fields statusMsg

Map of HTTP status codes to status messages

statusPhrase

Reason phrase to include in HTTP response line

statusCode

Get or set the HTTP status code for this response

methods redirect

Send a redirect response to the client using the specified status code and url

headers

Map of HTTP response headers

removeCookie

Remove a cookie for this response

done

Done is called to indicate that that response is complete to terminate pipeline processing

isDone

Return if this response is complete - see done

cookies

Get the list of cookies to set via header fields

isCommitted

Return true if this response has been commmited

out

Return the WebOutStream for this response

sendErr

Send an error response to client using the specified status and HTML formatted message

cookies abstract Cookie[] cookies()

Get the list of cookies to set via header fields. Add a a Cookie to this list to set a cookie. Throw an err if response is already committed.

Example:

res.cookies.add(Cookie("foo", "123"))
res.cookies.add(Cookie("persistent", "some val") { maxAge = 3day })

done abstract Void done()

Done is called to indicate that that response is complete to terminate pipeline processing.

headers abstract Str:Str headers()

Map of HTTP response headers. You must set all headers before you access out() for the first time, which commits the response. Throw an err if response is already committed.

isCommitted abstract Bool isCommitted()

Return true if this response has been commmited. A committed response has written its response headers, and can no longer modify its status code or headers. A response is committed the first time that out is called.

isDone abstract Bool isDone()

Return if this response is complete - see done.

out abstract WebOutStream out()

Return the WebOutStream for this response. The first time this method is accessed the response is committed: all headers currently set will be written to the stream, and can no longer be modified. If the "Content-Length" header defines a fixed number of bytes, then attemps to write too many bytes will throw an IOErr. If "Content-Length" is not defined, then a chunked transfer encoding is automatically used.

redirect abstract Void redirect(Uri uri, Int statusCode)

Send a redirect response to the client using the specified status code and url. If this response has already been committed this method throws an Err. This method implicitly calls done.

removeCookie Void removeCookie(Str name)

Remove a cookie for this response. This method is a convenience for:

res.cookies.add(Cookie(name, "") { maxAge=0day }

sendErr abstract Void sendErr(Int statusCode, Str? msg)

Send an error response to client using the specified status and HTML formatted message. If this response has already been committed this method throws an Err. This method implicitly calls done.

statusCode abstract Int : statusCode

Get or set the HTTP status code for this response. Status code defaults to 200. Throw an err if the response has already been committed.

statusMsg const static Int:Str : statusMsg

Map of HTTP status codes to status messages.

statusPhrase abstract Str? : statusPhrase

Reason phrase to include in HTTP response line. If null, then a status phrase is used based on the statusCode.

Haxall 4.0.5 ∙ 24-Feb-2026 14:33 EST