Skip to content
FutureBlitz

    Install

    Import std.net.http.client

    HttpResponse

    std.net.http.client

    class

    Public Class HttpResponse

    What a server answered: its status, its headers, its body's bytes, the URL it came from, after the redirects followed, and the HTTP it came over, "HTTP/1.1" or "HTTP/2".

    Examples

    Local response = HttpResponse(404, Headers(), "gone".Bytes, "https://example.com/old")
    Expect(!response.IsSuccess && response.Text == "gone")
    Expect(ExpectThrows<NetError>(response.EnsureSuccess())?.Kind == NetErrorKind.HTTP_STATUS)

    std/net/http/client.fb, line 139

    • Public ReadOnly Field Status: Int field #

      Its status, like 200 or 404.

    • Public ReadOnly Field Headers: Headers field #

      Its headers.

    • Public ReadOnly Field Bytes: UInt8[] field #

      Its body's bytes.

    • Public ReadOnly Field Url: String field #

      The URL it came from, after the redirects followed.

    • Public ReadOnly Field Version: String field #

      The HTTP it came over: "HTTP/1.1" or "HTTP/2".

    • Public New(status: Int, headers: Headers, bytes: UInt8[], url: String, version: String = "HTTP/1.1") constructor #

      A response of status, with headers and bytes, from url, over version.

    • Public Property Text: String property #

      The body as text, its UTF-8, with U+FFFD for each byte that doesn't start well-formed UTF-8.

    • Public Property IsSuccess: Bool property #

      Whether its Status says the request worked: from 200 to 299.

    • Public Method EnsureSuccess() Throws NetError method #

      Throws a NetError of HTTP_STATUS unless IsSuccess.

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