← index

[Web]Response

inherits [HTTP]ServerResponse · defined at web/03-response.qn:8

[Web]Response — the response handlers build: an [HTTP]ServerResponse with the builder conveniences. The threading setters (status:, header:value:, contentType:, body:) are inherited from the transport class, so a builder result chains further:

[Web]Response.json:user status:201 ([Web]Response.text:'hi').header:'X-Trace' value:tid

Class methods

bytes:

A 200 application/octet-stream response with raw Bytes b.

web/03-response.qn:35

html:

A 200 text/html (UTF-8) response with body s.

web/03-response.qn:24

json:

A 200 application/json response: v is JSON-generated into the body.

([Web]Response.json:#{'ok':true}).body.asString   "* -> {"ok":true}

web/03-response.qn:29

json: status:

A JSON response with an explicit status (e.g. 201 for a create).

web/03-response.qn:31

noContent

A 204 No Content response.

web/03-response.qn:39

redirect:

A 302 Found redirect to loc.

([Web]Response.redirect:'/login').headers   "* -> #(#(Location /login))

web/03-response.qn:44

redirect: status:

A redirect with an explicit 3xx status (301 / 303 / 307 / 308).

web/03-response.qn:46

status:

A bare response carrying just a status, no body.

web/03-response.qn:37

stream:

A streaming (chunked) response; each Generator yield is one chunk on the wire. The default content type fits server-sent events.

web/03-response.qn:51

stream: contentType:

A streaming (chunked) response with an explicit content type; each Generator yield is one chunk on the wire.

web/03-response.qn:54

text:

A 200 text/plain (UTF-8) response with body s.

([Web]Response.text:'hi').headers
"* -> #(#(Content-Type text/plain; charset=utf-8))

web/03-response.qn:22

Instance methods

init

Defaults for the bare-.new construction the builders use (guarded, so a config-block construction that already set them wins).

web/03-response.qn:11