crater-browser-http

HTTP, cache, cookie, and request sandbox helpers for crater browser

moon add mizchi/crater-browser-http@0.19.0
Download zip
Author
Version
0.19.0
License
Apache-2.0
Last updated
last month
Downloads
944

Dependencies

README

mizchi/crater-browser-http does not have a README file

#
HttpError

pub(all) suberror HttpError {
NetworkError(String)
InvalidUrl(String)
TimeoutError
CorsError(String)
SandboxError(String)
CorsBlocked(String)
PreflightFailed(String)
}

HTTP Error types
impl Show for HttpError

#
CredentialsMode

pub(all) enum CredentialsMode {
Omit
SameOrigin
Include
} derive(Eq,
Debug
)

Credentials mode for CORS checks

#
FetchOptions

pub(all) struct FetchOptions {
http_method : String
headers : Map[String, String]
body : String
timeout_ms : Int
mode : RequestMode
credentials : CredentialsMode
origin : String
sandbox : RequestSandbox
}

Fetch options

#
FetchOptions::default

fn FetchOptions::default() -> FetchOptions

#
HttpResponse

pub(all) struct HttpResponse {
status : Int
headers : Map[String, String]
body : String
}

HTTP Response structure

#
RequestMode

pub(all) enum RequestMode {
Navigate
SameOrigin
NoCors
Cors
} derive(Eq,
Debug
)

Request mode (subset of Fetch spec)

#
RequestSandbox

pub(all) enum RequestSandbox {
Open
SameOrigin
Allowlist(Array[String])
} derive(
Debug
)

Request sandbox policy

#
enforce_cors_response

fn enforce_cors_response(url : String, options : FetchOptions, response : HttpResponse) -> HttpResponse raise HttpError

Enforce CORS based on response headers

#
fetch

async fn fetch(url : String, options? : FetchOptions) -> HttpResponse raise HttpError

Fetch URL using native HTTP client

#
get_header

fn get_header(headers : Map[String, String], name : String) -> String?

#
headers_to_json

fn headers_to_json(headers : Map[String, String]) -> String

Convert headers map to JSON string

Powered by MoonBit

Site sourceReport issuePackagesBuild queueSkillsStatistics

© 2026 mooncakes.io