OxL Справочник OxL
РусскийEnglish

method Response.ok

Status 200..299.

Example:

oxl✓ проверяется в CI
use std.http { Response, Header }

fn sample() -> Response {
  Response{
    status: 200, reason: "OK", version: "1.1",
    headers: [Header{ name: "Content-Type", value: "text/plain" }, Header{ name: "Set-Cookie", value: "a=1" }, Header{ name: "Set-Cookie", value: "b=2" }],
    body: Utf8.encode("hello"), url: "http://example.org/", reused: false, redirects: 0
  }
}

fn main() io {
  var r = sample()
  print("{r.ok()}")
  r.status = 404
  print("{r.ok()}")
}
Вывод
true
false
pub(api) fn ok() -> bool

Сложность. O(1).

С версии. 1.0.0-beta

Возвращает

bool

Эффекты

не объявлены (чистая, пока тело не говорит иное)

Определено в: std/http/http.oxl:224

См. также