Import std.net.http.server
HttpResponse
extend
Extend HttpResponse
The responses a server's handlers give: one of a status and a body, and a redirect.
std/net/http/server.fb, line 158
-
@PanicsAtCaller Public Static Method Of(status: Int, body: Body? = Null): HttpResponsestatic method #A response of
status, withbody's bytes and its Content-Type, or an empty one. Thestatusis a final response's, from 200 to 599, or it panics: a 1xx's response comes before the one that answers, and a WebSocket's 101 comes from its AcceptAsync.Examples
Local missing = HttpResponse.Of(StatusCode.NOT_FOUND, Body.Text("no such page")) Expect(missing.Status == 404 && missing.Text == "no such page") Expect(HttpResponse.Redirect("/login").Headers.Get("Location") == "/login") -
A 200 with
body. -
@PanicsAtCaller Public Static Method Redirect(url: String, status: Int = 302): HttpResponsestatic method #A redirect to
url, which a header's value can hold, a 302 Found unlessstatussays another from 300 to 399, or it panics.
Report an issue with this page or with FutureBlitz on GitHub.