dymokomi/luce-browser-engine
Source of release 0.6.1
0.6.1 / src / web / fetch / infrastructure / http / statuses.lucb
#==============================================================================================
#
# statuses - null body, ok and redirect statuses
#
# DESCRIPTION:
# Port of Libraries/LibWeb/Fetch/Infrastructure/HTTP/Statuses.cpp (lines 12-36) with
# Statuses.h. A status (`Status`, an integer in the range 0 to 999) is a u16.
#
# Copyright (c) 2022, Linus Groh <linusg@serenityos.org>
# SPDX-License-Identifier: BSD-2-Clause
#
#==============================================================================================
## Ported from Libraries/LibWeb/Fetch/Infrastructure/HTTP/Statuses.cpp:14 Web::Fetch::Infrastructure::is_null_body_status.
# https://fetch.spec.whatwg.org/#null-body-status
pub func fetch_is_null_body_status(status: u16) -> bool:
# A null body status is a status that is 101, 103, 204, 205, or 304.
let null_body_statuses: u16[5] = [101, 103, 204, 205, 304]
for null_body_status in null_body_statuses:
if status == null_body_status:
return true
return false
## Ported from Libraries/LibWeb/Fetch/Infrastructure/HTTP/Statuses.cpp:23 Web::Fetch::Infrastructure::is_ok_status.
# https://fetch.spec.whatwg.org/#ok-status
pub func fetch_is_ok_status(status: u16) -> bool:
# An ok status is a status in the range 200 to 299, inclusive.
return status >= 200 and status <= 299
## Ported from Libraries/LibWeb/Fetch/Infrastructure/HTTP/Statuses.cpp:30 Web::Fetch::Infrastructure::is_redirect_status.
# https://fetch.spec.whatwg.org/#redirect-status
pub func fetch_is_redirect_status(status: u16) -> bool:
# A redirect status is a status that is 301, 302, 303, 307, or 308.
let redirect_statuses: u16[5] = [301, 302, 303, 307, 308]
for redirect_status in redirect_statuses:
if status == redirect_status:
return true
return false