Skip to content
FutureBlitz

    Install

    Import std.net.http.server

    HttpResponse

    std.net.http.server

    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): HttpResponse static method #

      A response of status, with body's bytes and its Content-Type, or an empty one. The status is 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")
    • Public Static Method Of(body: Body): HttpResponse static method #

      A 200 with body.

    • @PanicsAtCaller Public Static Method Redirect(url: String, status: Int = 302): HttpResponse static method #

      A redirect to url, which a header's value can hold, a 302 Found unless status says another from 300 to 399, or it panics.

    Report an issue with this page or with FutureBlitz on GitHub.