http11

moon add f4ah6o/http11@0.1.1
Download zip
Author
Version
0.1.1
License
Apache-2.0
Last updated
6 months ago
Downloads
69

Dependencies

README

#f4ah6o/http11

MoonBit で実装された Sans I/O な HTTP/1.1 パーサー・エンコーダーライブラリ。

#概要

本ライブラリは shiguredo/http11-rs を MoonBit に移植したものです。Sans I/O 設計により、I/O 処理を完全に分離しているため、任意のトランスポート(TCP、TLS、WebSocket 等)で使用できます。

  • 依存ライブラリなし: MoonBit 標準ライブラリのみで動作
  • DoS 攻撃対策: デコーダーリミット機能でリソース枯渇攻撃を防御
  • HTTP/1.1 準拠: Content-Length および chunked 転送エンコーディングに対応

#モジュール構成

#コアモジュール

ファイル説明
error.mbtHttpError enum - パースエラーの種類
limits.mbtDecoderLimits struct - デコーダー制限値
request.mbtRequest struct - HTTP リクエスト表現
response.mbtResponse struct - HTTP レスポンス表現
encoder.mbtリクエスト/レスポンスのエンコード関数
decoder.mbtRequestDecoder, ResponseDecoder - Sans I/O デコーダー

#URI / URL

ファイル説明
uri.mbtUri struct - URI パース(RFC 3986)、パーセントエンコード/デコード

#HTTP ヘッダー

ファイル説明
host.mbtHost struct - Host ヘッダー(RFC 9110)
expect.mbtExpect struct - Expect ヘッダー(RFC 9110)
trailer.mbtTrailer struct - Trailer ヘッダー(RFC 9112)
upgrade.mbtUpgrade struct - Upgrade ヘッダー(RFC 9110)
vary.mbtVary struct - Vary ヘッダー(RFC 9110)
range.mbtRange, ContentRange, AcceptRanges - Range 関連ヘッダー(RFC 9110)

#コンテント関連ヘッダー

ファイル説明
content_type.mbtContentType struct - Content-Type ヘッダー(RFC 9110)
content_encoding.mbtContentEncoding struct - Content-Encoding ヘッダー(RFC 9110)
content_disposition.mbtContentDisposition struct - Content-Disposition ヘッダー(RFC 6266)
content_language.mbtContentLanguage struct - Content-Language ヘッダー(RFC 9110)
content_location.mbtContentLocation struct - Content-Location ヘッダー(RFC 9110)

#キャッシュ / 認証

ファイル説明
etag.mbtEntityTag, ETagList - ETag 関連(RFC 9110)
cache.mbtCacheControl, Age, Expires - キャッシュ制御(RFC 9111)
conditional.mbtIfMatch, IfNoneMatch, IfModifiedSince など - 条件付きリクエスト(RFC 9110)
digest_fields.mbtContentDigest, ReprDigest, WantContentDigest など - ダイジェストフィールド(RFC 9530)

#認証 / クッキー / 受入

ファイル説明
auth.mbtBasicAuth, DigestAuth, BearerToken - HTTP 認証(RFC 7617, 7616, 6750)
cookie.mbtCookie, SetCookie - Cookie / Set-Cookie ヘッダー(RFC 6265)
accept.mbtAccept, AcceptCharset, AcceptEncoding, AcceptLanguage - コンテントネゴシエーション(RFC 9110)

#日付

ファイル説明
date.mbtHttpDate struct - HTTP-date パース(IMF-fixdate, RFC 850, ANSI C asctime)

#エラー型

///|
pub enum HttpError {
InvalidData(String) // 不正なデータ
BufferOverflow(Int, Int) // (size, limit)
TooManyHeaders(Int, Int) // (count, limit)
HeaderLineTooLong(Int, Int) // (size, limit)
BodyTooLarge(Int, Int) // (size, limit)
UnexpectedEof // 予期しない EOF
InvalidHeaderValue // 不正なヘッダー値
InvalidStatusCode // 不正なステータスコード
InvalidChunkSize // 不正なチャンクサイズ
}

#デコーダーリミット

///|
pub struct DecoderLimits {
max_buffer_size : Int // デフォルト: 65536
max_headers_count : Int // デフォルト: 100
max_header_line_size : Int // デフォルト: 8192
max_body_size : Int // デフォルト: 10485760 (10MB)
}

// デフォルトリミットで作成

///|
let decoder = RequestDecoder::new()

// カスタムリミットで作成

///|
let limits = {
max_buffer_size: 32768,
max_headers_count: 50,
max_header_line_size: 4096,
max_body_size: 5242880,
}

///|
let decoder = RequestDecoder::with_limits(limits)

// 無制限(テスト用途)

///|
let decoder = RequestDecoder::with_limits(DecoderLimits::unlimited())

#リクエスト

#作成とエンコード

// 基本的なリクエスト作成

///|
let req = Request::new("GET", "/test")
.header("Host", "example.com")
.header("Connection", "keep-alive")

// ボディ付きリクエスト

///|
let req = Request::new("POST", "/api")
.header("Content-Type", "application/json")
.body("{\"key\":\"value\"}".to_bytes())

// バージョン指定

///|
let req = Request::with_version("GET", "/", "HTTP/1.0")

// エンコード

///|
let encoded = encode_request(req)
// GET /test HTTP/1.1\r\nHost: example.com\r\nConnection: keep-alive\r\n\r\n

#ヘルパーメソッド

req.http_method() // "GET"
req.get_header("Host") // Some("example.com")
req.has_header("Host") // true
req.is_keep_alive() // true
req.content_length() // Some(123)
req.is_chunked() // false

#レスポンス

#作成とエンコード

// 基本的なレスポンス作成

///|
let resp = Response::new(200, "OK")
.header("Content-Type", "text/plain")
.header("Content-Length", "5")

// ボディ付きレスポンス

///|
let resp = Response::new(404, "Not Found")
.header("Content-Type", "text/html")
.body("<h1>Not Found</h1>".to_bytes())

// エンコード

///|
let encoded = encode_response(resp)
// HTTP/1.1 200 OK\r\nContent-Type: text/plain\r\nContent-Length: 5\r\n\r\n

#ステータスチェック

resp.is_success() // 200-299
resp.is_redirect() // 300-399
resp.is_client_error() // 400-499
resp.is_server_error() // 500-599

#デコーダー(Sans I/O)

#リクエストデコード

let decoder = RequestDecoder::new()

// データをフィード
decoder.feed(data)?

// デコード試行
match decoder.decode() {
Ok(Some(request)) => // リクエスト完了
// request.http_method, request.uri, request.headers, request.body
Ok(None) => // データが不十分 - 更にデータを feed して再試行
Err(e) => // エラー処理
}

// デコーダーをリセットして次のリクエストに備える
decoder.reset()

// 未処理のデータを取得
let remaining = decoder.remaining()

#レスポンスデコード

let decoder = ResponseDecoder::new()

decoder.feed(data)?
match decoder.decode() {
Ok(Some(response)) => // レスポンス完了
// response.status_code, response.reason_phrase, response.headers, response.body
Ok(None) => // データが不十分
Err(e) => // エラー処理
}

#URI パース(RFC 3986)

// URI パース

///|
let uri = Uri::parse("https://example.com:8080/path?query=value#fragment")

// アクセサー
uri.scheme() // Some("https")
uri.host() // Some("example.com")
uri.port() // Some(8080)
uri.path() // "/path"
uri.query() // Some("query=value")
uri.fragment() // Some("fragment")
uri.origin_form() // "/path?query=value"

#ヘッダーパース

#Host ヘッダー

let host = Host::parse("example.com:8080")
host.host() // "example.com"
host.port() // Some(8080)

#Content-Type ヘッダー

let ct = ContentType::parse("application/json; charset=utf-8")
ct.media_type() // "application"
ct.subtype() // "json"
ct.mime_type() // "application/json"
ct.charset() // Some("utf-8")
ct.is_json() // true

// Cookie ヘッダー

///|
let cookies = Cookie::parse("name1=value1; name2=value2")

// Set-Cookie ヘッダー

///|
let set_cookie = SetCookie::new("session", "abc123")
.with_domain("example.com")
.with_path("/")
.with_secure(true)
.with_http_only(true)

#認証

// Basic 認証

///|
let auth = BasicAuth::new("username", "password")

///|
let header_value = auth.to_header_value() // "Basic base64(...)"

///|
let parsed = BasicAuth::parse(header_value)

// Bearer トークン

///|
let token = BearerToken::parse("Bearer abc123")

#ETag

// ETag パース
let etag = EntityTag::parse("W/\"abc123\"")
etag.is_weak() // true
etag.tag() // "abc123"

// ETag リスト
let etags = parse_etag_list("*") // Any
etags.is_any() // true

#Range

// Range ヘッダー
let range = Range::parse("bytes=0-499")
range.unit() // "bytes"
range.ranges() // [Range(0UL, 499UL)]

// Content-Range ヘッダー
let cr = ContentRange::new_bytes(0UL, 499UL, Some(1000UL))
cr.to_string() // "bytes 0-499/1000"

#Chunked 転送エンコーディング

// チャンクエンコード

///|
let chunk1 = "Hello, ".to_bytes()

///|
let chunk2 = "world!".to_bytes()

///|
let encoded = encode_chunks([chunk1, chunk2])
// 7\r\nHello, \r\n6\r\nworld!\r\n0\r\n\r\n

// 単一チャンク

///|
let encoded = encode_chunk("data".to_bytes())
// 4\r\ndata\r\n

#サンプル

本ライブラリには3つの実行可能なサンプルプログラムが含まれています。

#実行方法

# 基本例 moon run cmd/main # HTTP クライアント moon run cmd/client # HTTP サーバー moon run cmd/server

#出力例

======================================== http11.mbt Example Program ======================================== 1. GET Request Example --- Encoded GET request: GET /api/users HTTP/1.1\r\n Host: example.com\r\n Connection: keep-alive\r\n Accept: application/json\r\n \r\n 2. POST Request with Body Example --- Encoded POST request: POST /api/users HTTP/1.1\r\n Host: example.com\r\n Content-Type: application/json\r\n \r\n {"name":"Alice","age":30} 3. Response Example --- Encoded response: HTTP/1.1 200 OK\r\n Content-Type: text/plain\r\n Content-Length: 13\r\n \r\n Hello, World! 4. Chunked Transfer Encoding Example --- Encoded chunked data: 7\r\n Hello, \r\n 6\r\n world!\r\n 0\r\n \r\n 5. Request Decoder Example --- RequestDecoder API usage: let decoder = @lib.RequestDecoder::new() decoder.feed(data) // Feed raw bytes decoder.decode() // Try to decode a request Note: Decoder is intended for use with network I/O 6. Response Decoder Example --- ResponseDecoder API usage: let decoder = @lib.ResponseDecoder::new() decoder.feed(data) // Feed raw bytes decoder.decode() // Try to decode a response Note: Decoder is intended for use with network I/O ======================================== All examples completed successfully! ========================================

#ライセンス

Portions derived from https://github.com/shiguredo/http11-rs Copyright 2026 Shiguredo Inc. Licensed under the Apache License, Version 2.0

本ライブラリ全体も Apache License 2.0 でライセンスされています。

#
Accept

pub(all) struct Accept {
items : Array[MediaRange]
}

Accept header (RFC 9110 Section 12.5)
impl Eq for Accept

#
Accept::items

fn Accept::items(self : Accept) -> Array[MediaRange]

#
Accept::parse

fn Accept::parse(input : String) -> Result[Accept, AcceptError]

#
Accept::to_string

fn Accept::to_string(self : Accept) -> String

#
AcceptCharset

pub(all) struct AcceptCharset {
items : Array[CharsetRange]
}

Accept-Charset header
impl Eq for AcceptCharset

#
AcceptCharset::items

#
AcceptCharset::parse

fn AcceptCharset::parse(input : String) -> Result[AcceptCharset, AcceptError]

#
AcceptEncoding

pub(all) struct AcceptEncoding {
items : Array[EncodingRange]
}

Accept-Encoding header

#
AcceptEncoding::items

#
AcceptEncoding::parse

fn AcceptEncoding::parse(input : String) -> Result[AcceptEncoding, AcceptError]

#
AcceptError

pub(all) enum AcceptError {
Empty
InvalidFormat
InvalidMediaRange
InvalidToken
InvalidParameter
InvalidQValue
InvalidLanguageTag
}

Accept header parsing errors (RFC 9110 Section 12.5)
impl Eq for AcceptError
impl Show for AcceptError

#
AcceptLanguage

pub(all) struct AcceptLanguage {
items : Array[LanguageRange]
}

Accept-Language header

#
AcceptLanguage::items

#
AcceptLanguage::parse

fn AcceptLanguage::parse(input : String) -> Result[AcceptLanguage, AcceptError]

#
AcceptRanges

pub(all) struct AcceptRanges {
units : Array[String]
}

Accept-Ranges header (RFC 9110 Section 14.3)
impl Eq for AcceptRanges

#
AcceptRanges::accepts_bytes

fn AcceptRanges::accepts_bytes(self : AcceptRanges) -> Bool

#
AcceptRanges::bytes

fn AcceptRanges::bytes() -> AcceptRanges

#
AcceptRanges::is_none

fn AcceptRanges::is_none(self : AcceptRanges) -> Bool

#
AcceptRanges::none

#
AcceptRanges::parse

fn AcceptRanges::parse(input : String) -> Result[AcceptRanges, RangeError]

#
AcceptRanges::to_string

fn AcceptRanges::to_string(self : AcceptRanges) -> String

#
AcceptRanges::units

fn AcceptRanges::units(self : AcceptRanges) -> Array[String]

#
Age

pub(all) struct Age {
seconds : Int
}

Age header (RFC 9111 Section 5.1)
impl Eq for Age

#
Age::new

fn Age::new(seconds : Int) -> Age

#
Age::parse

fn Age::parse(input : String) -> Result[Age, CacheError]

#
Age::seconds

fn Age::seconds(self : Age) -> Int

#
Age::to_string

fn Age::to_string(self : Age) -> String

#
AuthChallenge

pub(all) enum AuthChallenge {
Basic(WwwAuthenticate)
Digest(DigestChallenge)
Bearer(BearerChallenge)
}

WWW-Authenticate / Proxy-Authenticate challenge
impl Eq for AuthChallenge

#
AuthChallenge::parse

fn AuthChallenge::parse(input : String) -> Result[AuthChallenge, AuthError]

#
AuthChallenge::to_header_value

fn AuthChallenge::to_header_value(self : AuthChallenge) -> String

#
AuthChallenge::to_string

fn AuthChallenge::to_string(self : AuthChallenge) -> String

#
AuthError

pub(all) enum AuthError {
Empty
InvalidFormat
NotBasicScheme
NotDigestScheme
NotBearerScheme
Base64DecodeError
Utf8Error
MissingColon
InvalidParameter
MissingParameter
InvalidToken
}

Authentication error types
impl Eq for AuthError
impl Show for AuthError

#
Authorization

pub(all) enum Authorization {
Basic(BasicAuth)
Digest(DigestAuth)
Bearer(BearerToken)
}

Authorization header
impl Eq for Authorization

#
Authorization::parse

fn Authorization::parse(input : String) -> Result[Authorization, AuthError]

#
Authorization::to_header_value

fn Authorization::to_header_value(self : Authorization) -> String

#
Authorization::to_string

fn Authorization::to_string(self : Authorization) -> String

#
BasicAuth

pub(all) struct BasicAuth {
username : String
password : String
}

Basic Authentication (RFC 7617)
impl Eq for BasicAuth

#
BasicAuth::new

fn BasicAuth::new(username : String, password : String) -> BasicAuth

#
BasicAuth::parse

fn BasicAuth::parse(input : String) -> Result[BasicAuth, AuthError]

#
BasicAuth::password

fn BasicAuth::password(self : BasicAuth) -> String

#
BasicAuth::to_header_value

fn BasicAuth::to_header_value(self : BasicAuth) -> String

#
BasicAuth::to_string

fn BasicAuth::to_string(self : BasicAuth) -> String

#
BasicAuth::username

fn BasicAuth::username(self : BasicAuth) -> String

#
BearerChallenge

pub(all) struct BearerChallenge {
params : Array[(String, String)]
}

Bearer Challenge (WWW-Authenticate)

#
BearerChallenge::param

fn BearerChallenge::param(self : BearerChallenge, name : String) -> String?

#
BearerChallenge::parse

fn BearerChallenge::parse(input : String) -> Result[BearerChallenge, AuthError]

#
BearerChallenge::to_header_value

fn BearerChallenge::to_header_value(self : BearerChallenge) -> String

#
BearerChallenge::to_string

fn BearerChallenge::to_string(self : BearerChallenge) -> String

#
BearerToken

pub(all) struct BearerToken {
token : String
}

Bearer Token (RFC 6750)
impl Eq for BearerToken

#
BearerToken::parse

fn BearerToken::parse(input : String) -> Result[BearerToken, AuthError]

#
BearerToken::to_header_value

fn BearerToken::to_header_value(self : BearerToken) -> String

#
BearerToken::to_string

fn BearerToken::to_string(self : BearerToken) -> String

#
BearerToken::token

fn BearerToken::token(self : BearerToken) -> String

#
CacheControl

pub(all) struct CacheControl {
max_age : Int?
s_maxage : Int?
max_stale : Int?
min_fresh : Int?
stale_while_revalidate : Int?
stale_if_error : Int?
no_cache : Bool
no_store : Bool
no_transform : Bool
only_if_cached : Bool
must_revalidate : Bool
proxy_revalidate : Bool
must_understand : Bool
public : Bool
private : Bool
immutable : Bool
}

Cache-Control header (RFC 9111 Section 5.2)
impl Eq for CacheControl

#
CacheControl::is_cacheable

fn CacheControl::is_cacheable(self : CacheControl) -> Bool

#
CacheControl::is_immutable

fn CacheControl::is_immutable(self : CacheControl) -> Bool

#
CacheControl::is_must_revalidate

fn CacheControl::is_must_revalidate(self : CacheControl) -> Bool

#
CacheControl::is_must_understand

fn CacheControl::is_must_understand(self : CacheControl) -> Bool

#
CacheControl::is_no_cache

fn CacheControl::is_no_cache(self : CacheControl) -> Bool

#
CacheControl::is_no_store

fn CacheControl::is_no_store(self : CacheControl) -> Bool

#
CacheControl::is_no_transform

fn CacheControl::is_no_transform(self : CacheControl) -> Bool

#
CacheControl::is_only_if_cached

fn CacheControl::is_only_if_cached(self : CacheControl) -> Bool

#
CacheControl::is_private

fn CacheControl::is_private(self : CacheControl) -> Bool

#
CacheControl::is_proxy_revalidate

fn CacheControl::is_proxy_revalidate(self : CacheControl) -> Bool

#
CacheControl::is_public

fn CacheControl::is_public(self : CacheControl) -> Bool

#
CacheControl::max_age

fn CacheControl::max_age(self : CacheControl) -> Int?

#
CacheControl::max_stale

fn CacheControl::max_stale(self : CacheControl) -> Int?

#
CacheControl::min_fresh

fn CacheControl::min_fresh(self : CacheControl) -> Int?

#
CacheControl::new

#
CacheControl::parse

fn CacheControl::parse(input : String) -> Result[CacheControl, CacheError]

#
CacheControl::s_maxage

fn CacheControl::s_maxage(self : CacheControl) -> Int?

#
CacheControl::stale_if_error

fn CacheControl::stale_if_error(self : CacheControl) -> Int?

#
CacheControl::stale_while_revalidate

fn CacheControl::stale_while_revalidate(self : CacheControl) -> Int?

#
CacheControl::to_string

fn CacheControl::to_string(self : CacheControl) -> String

#
CacheControl::with_immutable

fn CacheControl::with_immutable(self : CacheControl) -> CacheControl

#
CacheControl::with_max_age

fn CacheControl::with_max_age(self : CacheControl, seconds : Int) -> CacheControl

#
CacheControl::with_must_revalidate

fn CacheControl::with_must_revalidate(self : CacheControl) -> CacheControl

#
CacheControl::with_no_cache

fn CacheControl::with_no_cache(self : CacheControl) -> CacheControl

#
CacheControl::with_no_store

fn CacheControl::with_no_store(self : CacheControl) -> CacheControl

#
CacheControl::with_no_transform

fn CacheControl::with_no_transform(self : CacheControl) -> CacheControl

#
CacheControl::with_only_if_cached

fn CacheControl::with_only_if_cached(self : CacheControl) -> CacheControl

#
CacheControl::with_private

fn CacheControl::with_private(self : CacheControl) -> CacheControl

#
CacheControl::with_proxy_revalidate

fn CacheControl::with_proxy_revalidate(self : CacheControl) -> CacheControl

#
CacheControl::with_public

fn CacheControl::with_public(self : CacheControl) -> CacheControl

#
CacheControl::with_s_maxage

fn CacheControl::with_s_maxage(self : CacheControl, seconds : Int) -> CacheControl

#
CacheError

pub(all) enum CacheError {
Empty
InvalidFormat
InvalidNumber
InvalidDate
}

Cache header parsing errors
impl Eq for CacheError
impl Show for CacheError

#
CharsetRange

pub(all) struct CharsetRange {
charset : String
q : QValue
}

Charset range for Accept-Charset
impl Eq for CharsetRange

#
CharsetRange::charset

fn CharsetRange::charset(self : CharsetRange) -> String

#
CharsetRange::qvalue

fn CharsetRange::qvalue(self : CharsetRange) -> QValue

#
CharsetRange::to_string

fn CharsetRange::to_string(self : CharsetRange) -> String

#
ConditionalError

pub(all) enum ConditionalError {
Empty
InvalidFormat
ETagError
DateError
}

Conditional request header parsing errors (RFC 9110 Section 13)

#
ContentCoding

pub(all) enum ContentCoding {
Gzip
Deflate
Compress
Identity
Br
Zstd
Other(String)
}

Content Coding (compression algorithm)
impl Eq for ContentCoding

#
ContentCoding::to_string

fn ContentCoding::to_string(self : ContentCoding) -> String

#
ContentDigest

pub(all) struct ContentDigest {
entries : Array[(String, DigestValue)]
}

Content-Digest header (RFC 9530)
impl Eq for ContentDigest

#
ContentDigest::entries

fn ContentDigest::entries(self : ContentDigest) -> Array[(String, DigestValue)]

#
ContentDigest::get

fn ContentDigest::get(self : ContentDigest, algorithm : String) -> DigestValue?

#
ContentDigest::parse

fn ContentDigest::parse(input : String) -> Result[ContentDigest, DigestFieldsError]

#
ContentDigest::to_string

fn ContentDigest::to_string(self : ContentDigest) -> String

#
ContentDisposition

pub(all) struct ContentDisposition {
disposition_type : DispositionType
filename : String?
filename_ext : String?
name : String?
parameters : Array[(String, String)]
}

Content-Disposition header (RFC 6266)

#
ContentDisposition::disposition_type

fn ContentDisposition::disposition_type(self : ContentDisposition) -> DispositionType

#
ContentDisposition::filename

fn ContentDisposition::filename(self : ContentDisposition) -> String?

#
ContentDisposition::filename_ascii

fn ContentDisposition::filename_ascii(self : ContentDisposition) -> String?

#
ContentDisposition::filename_ext

fn ContentDisposition::filename_ext(self : ContentDisposition) -> String?

#
ContentDisposition::is_attachment

fn ContentDisposition::is_attachment(self : ContentDisposition) -> Bool

#
ContentDisposition::is_form_data

fn ContentDisposition::is_form_data(self : ContentDisposition) -> Bool

#
ContentDisposition::is_inline

fn ContentDisposition::is_inline(self : ContentDisposition) -> Bool

#
ContentDisposition::name

fn ContentDisposition::name(self : ContentDisposition) -> String?

#
ContentDisposition::new

#
ContentDisposition::parameter

fn ContentDisposition::parameter(self : ContentDisposition, name : String) -> String?

#
ContentDisposition::parse

fn ContentDisposition::parse(input : String) -> Result[ContentDisposition, ContentDispositionError]

#
ContentDisposition::to_string

fn ContentDisposition::to_string(self : ContentDisposition) -> String

#
ContentDisposition::with_filename

fn ContentDisposition::with_filename(self : ContentDisposition, filename : String) -> ContentDisposition

#
ContentDisposition::with_filename_ext

fn ContentDisposition::with_filename_ext(self : ContentDisposition, filename_ext : String) -> ContentDisposition

#
ContentDisposition::with_name

fn ContentDisposition::with_name(self : ContentDisposition, name : String) -> ContentDisposition

#
ContentDispositionError

pub(all) enum ContentDispositionError {
Empty
InvalidFormat
InvalidDispositionType
InvalidParameter
InvalidExtValue
}

Content-Disposition header parsing errors (RFC 6266)

#
ContentEncoding

pub(all) struct ContentEncoding {
encodings : Array[ContentCoding]
}

Content-Encoding header (RFC 9110 Section 8.4)

#
ContentEncoding::encodings

#
ContentEncoding::has_br

fn ContentEncoding::has_br(self : ContentEncoding) -> Bool

#
ContentEncoding::has_compress

fn ContentEncoding::has_compress(self : ContentEncoding) -> Bool

#
ContentEncoding::has_deflate

fn ContentEncoding::has_deflate(self : ContentEncoding) -> Bool

#
ContentEncoding::has_gzip

fn ContentEncoding::has_gzip(self : ContentEncoding) -> Bool

#
ContentEncoding::has_identity

fn ContentEncoding::has_identity(self : ContentEncoding) -> Bool

#
ContentEncoding::has_zstd

fn ContentEncoding::has_zstd(self : ContentEncoding) -> Bool

#
ContentEncoding::parse

fn ContentEncoding::parse(input : String) -> Result[ContentEncoding, ContentEncodingError]

#
ContentEncoding::to_string

fn ContentEncoding::to_string(self : ContentEncoding) -> String

#
ContentEncodingError

pub(all) enum ContentEncodingError {
Empty
InvalidFormat
InvalidEncoding
}

Content-Encoding header parsing errors (RFC 9110 Section 8.4)

#
ContentLanguage

pub(all) struct ContentLanguage {
tags : Array[String]
}

Content-Language header (RFC 9110 Section 8.5)

#
ContentLanguage::parse

fn ContentLanguage::parse(input : String) -> Result[ContentLanguage, ContentLanguageError]

#
ContentLanguage::tags

fn ContentLanguage::tags(self : ContentLanguage) -> Array[String]

#
ContentLanguage::to_string

fn ContentLanguage::to_string(self : ContentLanguage) -> String

#
ContentLanguageError

pub(all) enum ContentLanguageError {
Empty
InvalidFormat
InvalidLanguageTag
}

Content-Language header parsing errors (RFC 9110 Section 8.5)

#
ContentLocation

pub(all) struct ContentLocation {
uri : Uri
}

Content-Location header (RFC 9110 Section 8.6)

#
ContentLocation::parse

fn ContentLocation::parse(input : String) -> Result[ContentLocation, ContentLocationError]

#
ContentLocation::to_string

fn ContentLocation::to_string(self : ContentLocation) -> String

#
ContentLocation::uri

#
ContentLocationError

pub(all) enum ContentLocationError {
Empty
InvalidUri
}

Content-Location header parsing errors (RFC 9110 Section 8.6)

#
ContentRange

pub(all) struct ContentRange {
unit : String
start : UInt64?
end : UInt64?
complete_length : UInt64?
}

Content-Range header (RFC 9110 Section 14.4)
impl Eq for ContentRange

#
ContentRange::complete_length

fn ContentRange::complete_length(self : ContentRange) -> UInt64?

#
ContentRange::end

fn ContentRange::end(self : ContentRange) -> UInt64?

#
ContentRange::is_unsatisfied

fn ContentRange::is_unsatisfied(self : ContentRange) -> Bool

#
ContentRange::length

fn ContentRange::length(self : ContentRange) -> UInt64?

#
ContentRange::new_bytes

fn ContentRange::new_bytes(start : UInt64, end : UInt64, complete_length : UInt64?) -> ContentRange

#
ContentRange::parse

fn ContentRange::parse(input : String) -> Result[ContentRange, RangeError]

#
ContentRange::start

fn ContentRange::start(self : ContentRange) -> UInt64?

#
ContentRange::to_string

fn ContentRange::to_string(self : ContentRange) -> String

#
ContentRange::unit

fn ContentRange::unit(self : ContentRange) -> String

#
ContentRange::unsatisfied

fn ContentRange::unsatisfied(unit : String, complete_length : UInt64) -> ContentRange

#
ContentType

pub(all) struct ContentType {
media_type : String
subtype : String
parameters : Array[(String, String)]
}

Content-Type header (RFC 9110 Section 8.3)
impl Eq for ContentType

#
ContentType::boundary

fn ContentType::boundary(self : ContentType) -> String?

#
ContentType::charset

fn ContentType::charset(self : ContentType) -> String?

#
ContentType::is_form_data

fn ContentType::is_form_data(self : ContentType) -> Bool

#
ContentType::is_form_urlencoded

fn ContentType::is_form_urlencoded(self : ContentType) -> Bool

#
ContentType::is_json

fn ContentType::is_json(self : ContentType) -> Bool

#
ContentType::is_multipart

fn ContentType::is_multipart(self : ContentType) -> Bool

#
ContentType::is_text

fn ContentType::is_text(self : ContentType) -> Bool

#
ContentType::media_type

fn ContentType::media_type(self : ContentType) -> String

#
ContentType::mime_type

fn ContentType::mime_type(self : ContentType) -> String

#
ContentType::new

fn ContentType::new(media_type : String, subtype : String) -> ContentType

#
ContentType::parameter

fn ContentType::parameter(self : ContentType, name : String) -> String?

#
ContentType::parameters

fn ContentType::parameters(self : ContentType) -> Array[(String, String)]

#
ContentType::parse

fn ContentType::parse(input : String) -> Result[ContentType, ContentTypeError]

#
ContentType::subtype

fn ContentType::subtype(self : ContentType) -> String

#
ContentType::to_string

fn ContentType::to_string(self : ContentType) -> String

#
ContentType::with_parameter

fn ContentType::with_parameter(self : ContentType, name : String, value : String) -> ContentType

#
ContentTypeError

pub(all) enum ContentTypeError {
Empty
InvalidMediaType
InvalidParameter
UnterminatedQuote
}

Content-Type header parsing errors (RFC 9110 Section 8.3)
pub(all) struct Cookie {
name : String
value : String
}

Cookie (name=value pair)
impl Eq for Cookie

#
Cookie::name

fn Cookie::name(self : Cookie) -> String

#
Cookie::new

fn Cookie::new(name : String, value : String) -> Result[Cookie, CookieError]

#
Cookie::parse

fn Cookie::parse(input : String) -> Result[Array[Cookie], CookieError]

#
Cookie::to_string

fn Cookie::to_string(self : Cookie) -> String

#
Cookie::value

fn Cookie::value(self : Cookie) -> String

#
CookieError

pub(all) enum CookieError {
Empty
InvalidFormat
InvalidName
InvalidValue
InvalidAttribute
InvalidExpires
InvalidMaxAge
InvalidSameSite
}

Cookie parsing errors (RFC 6265)
impl Eq for CookieError
impl Show for CookieError

#
DateError

pub(all) enum DateError {
Empty
InvalidFormat
InvalidDayName
InvalidDay
InvalidMonth
InvalidYear
InvalidHour
InvalidMinute
InvalidSecond
NotGmt
}

HTTP-date parsing errors
impl Eq for DateError
impl Show for DateError

#
DayOfWeek

pub(all) enum DayOfWeek {
Sunday
Monday
Tuesday
Wednesday
Thursday
Friday
Saturday
}

Day of week
impl Eq for DayOfWeek
impl Show for DayOfWeek

#
DecodeState

pub(all) enum DecodeState {
Start
StartLine
Headers
Body(Int)
Complete
}

Decoder state machine
impl Eq for DecodeState
impl Show for DecodeState

#
DecoderLimits

pub(all) struct DecoderLimits {
max_buffer_size : Int
max_headers_count : Int
max_header_line_size : Int
max_body_size : Int
}

Decoder limits to prevent resource exhaustion
impl Eq for DecoderLimits

#
DecoderLimits::default

fn DecoderLimits::default() -> DecoderLimits

#
DecoderLimits::unlimited

fn DecoderLimits::unlimited() -> DecoderLimits

#
DigestAuth

pub(all) struct DigestAuth {
params : Array[(String, String)]
}

Digest Authentication (Authorization)
impl Eq for DigestAuth

#
DigestAuth::nonce

fn DigestAuth::nonce(self : DigestAuth) -> String?

#
DigestAuth::param

fn DigestAuth::param(self : DigestAuth, name : String) -> String?

#
DigestAuth::parse

fn DigestAuth::parse(input : String) -> Result[DigestAuth, AuthError]

#
DigestAuth::realm

fn DigestAuth::realm(self : DigestAuth) -> String?

#
DigestAuth::response

fn DigestAuth::response(self : DigestAuth) -> String?

#
DigestAuth::to_header_value

fn DigestAuth::to_header_value(self : DigestAuth) -> String

#
DigestAuth::to_string

fn DigestAuth::to_string(self : DigestAuth) -> String

#
DigestAuth::uri

fn DigestAuth::uri(self : DigestAuth) -> String?

#
DigestAuth::username

fn DigestAuth::username(self : DigestAuth) -> String?

#
DigestChallenge

pub(all) struct DigestChallenge {
params : Array[(String, String)]
}

Digest Authentication Challenge (WWW-Authenticate)

#
DigestChallenge::nonce

fn DigestChallenge::nonce(self : DigestChallenge) -> String?

#
DigestChallenge::param

fn DigestChallenge::param(self : DigestChallenge, name : String) -> String?

#
DigestChallenge::parse

fn DigestChallenge::parse(input : String) -> Result[DigestChallenge, AuthError]

#
DigestChallenge::realm

fn DigestChallenge::realm(self : DigestChallenge) -> String?

#
DigestChallenge::to_header_value

fn DigestChallenge::to_header_value(self : DigestChallenge) -> String

#
DigestChallenge::to_string

fn DigestChallenge::to_string(self : DigestChallenge) -> String

#
DigestEntry

pub(all) struct DigestEntry {
algorithm : String
value : DigestValue
}

Digest entry (algorithm + digest value)
impl Eq for DigestEntry

#
DigestEntry::algorithm

fn DigestEntry::algorithm(self : DigestEntry) -> String

#
DigestEntry::new

fn DigestEntry::new(algorithm : String, value : DigestValue) -> DigestEntry

#
DigestEntry::to_string

fn DigestEntry::to_string(self : DigestEntry) -> String

#
DigestEntry::value

fn DigestEntry::value(self : DigestEntry) -> DigestValue

#
DigestFieldsError

pub(all) enum DigestFieldsError {
Empty
InvalidFormat
InvalidAlgorithm
InvalidByteSequence
InvalidBase64
InvalidPreference
}

Digest fields error types

#
DigestPreference

pub(all) struct DigestPreference {
algorithm : String
weight : Int
}

Digest preference (algorithm + weight 0-10)

#
DigestPreference::algorithm

fn DigestPreference::algorithm(self : DigestPreference) -> String

#
DigestPreference::new

fn DigestPreference::new(algorithm : String, weight : Int) -> DigestPreference

#
DigestPreference::to_string

fn DigestPreference::to_string(self : DigestPreference) -> String

#
DigestPreference::weight

fn DigestPreference::weight(self : DigestPreference) -> Int

#
DigestValue

pub(all) struct DigestValue {
bytes : Array[Byte]
}

Digest value (RFC 9530 section 4) Format: :base64:
impl Eq for DigestValue

#
DigestValue::bytes

fn DigestValue::bytes(self : DigestValue) -> Array[Byte]

#
DigestValue::new

fn DigestValue::new(bytes : Array[Byte]) -> DigestValue

#
DigestValue::to_string

fn DigestValue::to_string(self : DigestValue) -> String

#
DispositionType

pub(all) enum DispositionType {
Inline
Attachment
FormData
}

Disposition type

#
DispositionType::to_string

fn DispositionType::to_string(self : DispositionType) -> String

#
ETagError

pub(all) enum ETagError {
Empty
InvalidFormat
MissingQuote
InvalidCharacter
}

ETag parsing errors
impl Eq for ETagError
impl Show for ETagError

#
ETagList

pub(all) enum ETagList {
Any
Tags(Array[EntityTag])
}

ETag list for If-Match, If-None-Match headers
impl Eq for ETagList
impl Show for ETagList

#
ETagList::contains_strong

fn ETagList::contains_strong(self : ETagList, etag : EntityTag) -> Bool

#
ETagList::contains_weak

fn ETagList::contains_weak(self : ETagList, etag : EntityTag) -> Bool

#
ETagList::is_any

fn ETagList::is_any(self : ETagList) -> Bool

#
ETagList::to_string

fn ETagList::to_string(self : ETagList) -> String

#
EncodingRange

pub(all) struct EncodingRange {
coding : String
q : QValue
}

Encoding range for Accept-Encoding
impl Eq for EncodingRange

#
EncodingRange::coding

fn EncodingRange::coding(self : EncodingRange) -> String

#
EncodingRange::qvalue

fn EncodingRange::qvalue(self : EncodingRange) -> QValue

#
EncodingRange::to_string

fn EncodingRange::to_string(self : EncodingRange) -> String

#
EntityTag

pub(all) struct EntityTag {
weak : Bool
tag : String
}

Entity Tag (ETag) (RFC 9110 Section 8.8.3)
impl Eq for EntityTag
impl Show for EntityTag

#
EntityTag::is_strong

fn EntityTag::is_strong(self : EntityTag) -> Bool

#
EntityTag::is_weak

fn EntityTag::is_weak(self : EntityTag) -> Bool

#
EntityTag::parse

fn EntityTag::parse(input : String) -> Result[EntityTag, ETagError]

#
EntityTag::strong

fn EntityTag::strong(tag : String) -> Result[EntityTag, ETagError]

#
EntityTag::strong_compare

fn EntityTag::strong_compare(self : EntityTag, other : EntityTag) -> Bool

#
EntityTag::tag

fn EntityTag::tag(self : EntityTag) -> String

#
EntityTag::to_string

fn EntityTag::to_string(self : EntityTag) -> String

#
EntityTag::weak

fn EntityTag::weak(tag : String) -> Result[EntityTag, ETagError]

#
EntityTag::weak_compare

fn EntityTag::weak_compare(self : EntityTag, other : EntityTag) -> Bool

#
Expect

pub(all) struct Expect {
items : Array[Expectation]
}

Expect header (RFC 9110 Section 10.1.1)
impl Eq for Expect
impl Show for Expect

#
Expect::has_100_continue

fn Expect::has_100_continue(self : Expect) -> Bool

#
Expect::items

fn Expect::items(self : Expect) -> Array[Expectation]

#
Expect::parse

fn Expect::parse(input : String) -> Result[Expect, ExpectError]

#
Expect::to_string

fn Expect::to_string(self : Expect) -> String

#
ExpectError

pub(all) enum ExpectError {
Empty
InvalidFormat
InvalidToken
InvalidValue
}

Expect header parsing errors (RFC 9110 Section 10.1.1)
impl Eq for ExpectError
impl Show for ExpectError

#
Expectation

pub(all) struct Expectation {
token : String
value : String?
}

Expectation item
impl Eq for Expectation
impl Show for Expectation

#
Expectation::is_100_continue

fn Expectation::is_100_continue(self : Expectation) -> Bool

#
Expectation::to_string

fn Expectation::to_string(self : Expectation) -> String

#
Expectation::token

fn Expectation::token(self : Expectation) -> String

#
Expectation::value

fn Expectation::value(self : Expectation) -> String?

#
Expires

pub(all) struct Expires {
date : HttpDate
}

Expires header (RFC 9111 Section 5.3)
impl Eq for Expires

#
Expires::date

fn Expires::date(self : Expires) -> HttpDate

#
Expires::new

fn Expires::new(date : HttpDate) -> Expires

#
Expires::parse

fn Expires::parse(input : String) -> Result[Expires, CacheError]

#
Expires::to_string

fn Expires::to_string(self : Expires) -> String

#
Host

pub(all) struct Host {
host : String
port : Int?
}

Host header (RFC 9110 Section 7.2)
impl Eq for Host
impl Show for Host

#
Host::host

fn Host::host(self : Host) -> String

#
Host::is_ipv6

fn Host::is_ipv6(self : Host) -> Bool

#
Host::parse

fn Host::parse(input : String) -> Result[Host, HostError]

#
Host::port

fn Host::port(self : Host) -> Int?

#
Host::to_string

fn Host::to_string(self : Host) -> String

#
HostError

pub(all) enum HostError {
Empty
InvalidFormat
InvalidHost
InvalidPort
}

Host header parsing errors (RFC 9110 Section 7.2)
impl Eq for HostError
impl Show for HostError

#
HttpDate

pub(all) struct HttpDate {
day_of_week : DayOfWeek
day : Int
month : Int
year : Int
hour : Int
minute : Int
second : Int
}

HTTP-date structure (RFC 9110 Section 5.6.7)

Supports three formats:
  • IMF-fixdate: Sun, 06 Nov 1994 08:49:37 GMT (preferred)
  • RFC 850: Sunday, 06-Nov-94 08:49:37 GMT (obsolete)
  • ANSI C asctime: Sun Nov 6 08:49:37 1994 (obsolete)
impl Eq for HttpDate
impl Show for HttpDate

#
HttpDate::day

fn HttpDate::day(self : HttpDate) -> Int

#
HttpDate::day_of_week

fn HttpDate::day_of_week(self : HttpDate) -> DayOfWeek

#
HttpDate::hour

fn HttpDate::hour(self : HttpDate) -> Int

#
HttpDate::minute

fn HttpDate::minute(self : HttpDate) -> Int

#
HttpDate::month

fn HttpDate::month(self : HttpDate) -> Int

#
HttpDate::new

fn HttpDate::new(day_of_week : DayOfWeek, day : Int, month : Int, year : Int, hour : Int, minute : Int, second : Int) -> Result[HttpDate, DateError]

#
HttpDate::parse

fn HttpDate::parse(input : String) -> Result[HttpDate, DateError]

#
HttpDate::second

fn HttpDate::second(self : HttpDate) -> Int

#
HttpDate::to_string

fn HttpDate::to_string(self : HttpDate) -> String

#
HttpDate::year

fn HttpDate::year(self : HttpDate) -> Int

#
HttpError

pub(all) enum HttpError {
InvalidData(String)
BufferOverflow(Int, Int)
TooManyHeaders(Int, Int)
HeaderLineTooLong(Int, Int)
BodyTooLarge(Int, Int)
UnexpectedEof
InvalidHeaderValue
InvalidStatusCode
InvalidChunkSize
}

HTTP parsing errors
impl Eq for HttpError
impl Show for HttpError

#
IfMatch

pub(all) struct IfMatch {
etags : ETagList
}

If-Match header (RFC 9110 Section 13.1.1)
impl Eq for IfMatch

#
IfMatch::etags

fn IfMatch::etags(self : IfMatch) -> ETagList

#
IfMatch::is_any

fn IfMatch::is_any(self : IfMatch) -> Bool

#
IfMatch::matches

fn IfMatch::matches(self : IfMatch, etag : EntityTag) -> Bool

#
IfMatch::parse

fn IfMatch::parse(input : String) -> Result[IfMatch, ConditionalError]

#
IfMatch::to_string

fn IfMatch::to_string(self : IfMatch) -> String

#
IfModifiedSince

pub(all) struct IfModifiedSince {
date : HttpDate
}

If-Modified-Since header (RFC 9110 Section 13.1.3)

#
IfModifiedSince::date

#
IfModifiedSince::parse

fn IfModifiedSince::parse(input : String) -> Result[IfModifiedSince, ConditionalError]

#
IfModifiedSince::to_string

fn IfModifiedSince::to_string(self : IfModifiedSince) -> String

#
IfNoneMatch

pub(all) struct IfNoneMatch {
etags : ETagList
}

If-None-Match header (RFC 9110 Section 13.1.2)
impl Eq for IfNoneMatch

#
IfNoneMatch::etags

fn IfNoneMatch::etags(self : IfNoneMatch) -> ETagList

#
IfNoneMatch::is_any

fn IfNoneMatch::is_any(self : IfNoneMatch) -> Bool

#
IfNoneMatch::matches

fn IfNoneMatch::matches(self : IfNoneMatch, etag : EntityTag) -> Bool

#
IfNoneMatch::parse

fn IfNoneMatch::parse(input : String) -> Result[IfNoneMatch, ConditionalError]

#
IfNoneMatch::to_string

fn IfNoneMatch::to_string(self : IfNoneMatch) -> String

#
IfRange

pub(all) enum IfRange {
ETag(EntityTag)
Date(HttpDate)
}

If-Range header (RFC 9110 Section 13.1.5)
impl Eq for IfRange

#
IfRange::date

fn IfRange::date(self : IfRange) -> HttpDate?

#
IfRange::etag

fn IfRange::etag(self : IfRange) -> EntityTag?

#
IfRange::is_date

fn IfRange::is_date(self : IfRange) -> Bool

#
IfRange::is_etag

fn IfRange::is_etag(self : IfRange) -> Bool

#
IfRange::parse

fn IfRange::parse(input : String) -> Result[IfRange, ConditionalError]

#
IfRange::to_string

fn IfRange::to_string(self : IfRange) -> String

#
IfUnmodifiedSince

pub(all) struct IfUnmodifiedSince {
date : HttpDate
}

If-Unmodified-Since header (RFC 9110 Section 13.1.4)

#
IfUnmodifiedSince::date

#
IfUnmodifiedSince::parse

fn IfUnmodifiedSince::parse(input : String) -> Result[IfUnmodifiedSince, ConditionalError]

#
IfUnmodifiedSince::to_string

fn IfUnmodifiedSince::to_string(self : IfUnmodifiedSince) -> String

#
LanguageRange

pub(all) struct LanguageRange {
language : String
q : QValue
}

Language range for Accept-Language
impl Eq for LanguageRange

#
LanguageRange::language

fn LanguageRange::language(self : LanguageRange) -> String

#
LanguageRange::qvalue

fn LanguageRange::qvalue(self : LanguageRange) -> QValue

#
LanguageRange::to_string

fn LanguageRange::to_string(self : LanguageRange) -> String

#
MediaRange

pub(all) struct MediaRange {
media_type : String
subtype : String
parameters : Array[(String, String)]
q : QValue
}

Media range for Accept header
impl Eq for MediaRange

#
MediaRange::media_type

fn MediaRange::media_type(self : MediaRange) -> String

#
MediaRange::parameters

fn MediaRange::parameters(self : MediaRange) -> Array[(String, String)]

#
MediaRange::qvalue

fn MediaRange::qvalue(self : MediaRange) -> QValue

#
MediaRange::subtype

fn MediaRange::subtype(self : MediaRange) -> String

#
MediaRange::to_string

fn MediaRange::to_string(self : MediaRange) -> String

#
Protocol

pub(all) struct Protocol {
name : String
version : String?
}

Upgrade protocol
impl Eq for Protocol
impl Show for Protocol

#
Protocol::name

fn Protocol::name(self : Protocol) -> String

#
Protocol::to_string

fn Protocol::to_string(self : Protocol) -> String

#
Protocol::version

fn Protocol::version(self : Protocol) -> String?

#
ProxyAuthenticate

pub(all) struct ProxyAuthenticate {
challenge : AuthChallenge
}

Proxy-Authenticate header

#
ProxyAuthenticate::challenge

#
ProxyAuthenticate::parse

fn ProxyAuthenticate::parse(input : String) -> Result[ProxyAuthenticate, AuthError]

#
ProxyAuthenticate::to_header_value

fn ProxyAuthenticate::to_header_value(self : ProxyAuthenticate) -> String

#
ProxyAuthenticate::to_string

fn ProxyAuthenticate::to_string(self : ProxyAuthenticate) -> String

#
ProxyAuthorization

pub(all) struct ProxyAuthorization {
auth : Authorization
}

Proxy-Authorization header

#
ProxyAuthorization::authorization

#
ProxyAuthorization::parse

fn ProxyAuthorization::parse(input : String) -> Result[ProxyAuthorization, AuthError]

#
ProxyAuthorization::to_header_value

fn ProxyAuthorization::to_header_value(self : ProxyAuthorization) -> String

#
ProxyAuthorization::to_string

fn ProxyAuthorization::to_string(self : ProxyAuthorization) -> String

#
QValue

pub(all) struct QValue {
value : Int
}

Q value (0.000 - 1.000)
impl Eq for QValue

#
QValue::parse

fn QValue::parse(input : String) -> Result[QValue, AcceptError]

#
QValue::to_string

fn QValue::to_string(self : QValue) -> String

#
QValue::value

fn QValue::value(self : QValue) -> Int

#
Range

pub(all) struct Range {
unit : String
ranges : Array[RangeSpec]
}

Range header (RFC 9110 Section 14.2)
impl Eq for Range

#
Range::first

fn Range::first(self : Range) -> RangeSpec?

#
Range::is_bytes

fn Range::is_bytes(self : Range) -> Bool

#
Range::parse

fn Range::parse(input : String) -> Result[Range, RangeError]

#
Range::ranges

fn Range::ranges(self : Range) -> Array[RangeSpec]

#
Range::to_string

fn Range::to_string(self : Range) -> String

#
Range::unit

fn Range::unit(self : Range) -> String

#
RangeError

pub(all) enum RangeError {
Empty
InvalidFormat
InvalidUnit
InvalidRange
InvalidBounds
}

Range header parsing errors (RFC 9110)
impl Eq for RangeError
impl Show for RangeError

#
RangeSpec

pub(all) enum RangeSpec {
Range(UInt64, UInt64)
FromStart(UInt64)
Suffix(UInt64)
}

Range specification (RFC 9110 Section 14.2)
impl Eq for RangeSpec

#
RangeSpec::to_bounds

fn RangeSpec::to_bounds(self : RangeSpec, total_length : UInt64) -> (UInt64, UInt64)?

#
RangeSpec::to_string

fn RangeSpec::to_string(self : RangeSpec) -> String

#
ReprDigest

pub(all) struct ReprDigest {
entries : Array[(String, DigestValue)]
}

Repr-Digest header (RFC 9530)
impl Eq for ReprDigest

#
ReprDigest::entries

fn ReprDigest::entries(self : ReprDigest) -> Array[(String, DigestValue)]

#
ReprDigest::get

fn ReprDigest::get(self : ReprDigest, algorithm : String) -> DigestValue?

#
ReprDigest::parse

fn ReprDigest::parse(input : String) -> Result[ReprDigest, DigestFieldsError]

#
ReprDigest::to_string

fn ReprDigest::to_string(self : ReprDigest) -> String

#
Request

pub(all) struct Request {
http_method : String
uri : String
version : String
headers : Array[(String, String)]
body : Array[Byte]
}

HTTP Request representation
impl Eq for Request
impl Show for Request

#
Request::body

fn Request::body(self : Request, body : Array[Byte]) -> Request

#
Request::content_length

fn Request::content_length(self : Request) -> Int?

#
Request::get_header

fn Request::get_header(self : Request, name : String) -> String?

#
Request::has_header

fn Request::has_header(self : Request, name : String) -> Bool

#
Request::header

fn Request::header(self : Request, name : String, value : String) -> Request

#
Request::http_method

fn Request::http_method(self : Request) -> String

#
Request::is_chunked

fn Request::is_chunked(self : Request) -> Bool

#
Request::is_keep_alive

fn Request::is_keep_alive(self : Request) -> Bool

#
Request::new

fn Request::new(http_method : String, uri : String) -> Request

#
Request::with_version

fn Request::with_version(http_method : String, uri : String, version : String) -> Request

#
RequestDecoder

pub(all) struct RequestDecoder {
buf : Array[Byte]
state : DecodeState
parsed_method : String?
parsed_uri : String?
parsed_version : String?
headers : Array[(String, String)]
body_buf : Array[Byte]
content_length : Int?
limits : DecoderLimits
}

Sans I/O HTTP request decoder

#
RequestDecoder::decode

fn RequestDecoder::decode(self : RequestDecoder) -> Result[Request?, HttpError]

#
RequestDecoder::feed

fn RequestDecoder::feed(self : RequestDecoder, data : Array[Byte]) -> Result[Unit, HttpError]

#
RequestDecoder::new

#
RequestDecoder::remaining

fn RequestDecoder::remaining(self : RequestDecoder) -> Array[Byte]

#
RequestDecoder::reset

fn RequestDecoder::reset(self : RequestDecoder) -> Unit

#
RequestDecoder::with_limits

fn RequestDecoder::with_limits(limits : DecoderLimits) -> RequestDecoder

#
Response

pub(all) struct Response {
version : String
status_code : Int
reason_phrase : String
headers : Array[(String, String)]
body : Array[Byte]
}

HTTP Response representation
impl Eq for Response
impl Show for Response

#
Response::body

fn Response::body(self : Response, body : Array[Byte]) -> Response

#
Response::content_length

fn Response::content_length(self : Response) -> Int?

#
Response::get_header

fn Response::get_header(self : Response, name : String) -> String?

#
Response::has_header

fn Response::has_header(self : Response, name : String) -> Bool

#
Response::header

fn Response::header(self : Response, name : String, value : String) -> Response

#
Response::is_chunked

fn Response::is_chunked(self : Response) -> Bool

#
Response::is_client_error

fn Response::is_client_error(self : Response) -> Bool

#
Response::is_keep_alive

fn Response::is_keep_alive(self : Response) -> Bool

#
Response::is_redirect

fn Response::is_redirect(self : Response) -> Bool

#
Response::is_server_error

fn Response::is_server_error(self : Response) -> Bool

#
Response::is_success

fn Response::is_success(self : Response) -> Bool

#
Response::new

fn Response::new(status_code : Int, reason_phrase : String) -> Response

#
Response::with_version

fn Response::with_version(version : String, status_code : Int, reason_phrase : String) -> Response

#
ResponseDecoder

pub(all) struct ResponseDecoder {
buf : Array[Byte]
state : DecodeState
parsed_version : String?
parsed_status_code : Int?
parsed_reason : String?
headers : Array[(String, String)]
body_buf : Array[Byte]
content_length : Int?
limits : DecoderLimits
}

Sans I/O HTTP response decoder

#
ResponseDecoder::decode

fn ResponseDecoder::decode(self : ResponseDecoder) -> Result[Response?, HttpError]

#
ResponseDecoder::feed

fn ResponseDecoder::feed(self : ResponseDecoder, data : Array[Byte]) -> Result[Unit, HttpError]

#
ResponseDecoder::new

#
ResponseDecoder::remaining

fn ResponseDecoder::remaining(self : ResponseDecoder) -> Array[Byte]

#
ResponseDecoder::reset

fn ResponseDecoder::reset(self : ResponseDecoder) -> Unit

#
ResponseDecoder::with_limits

fn ResponseDecoder::with_limits(limits : DecoderLimits) -> ResponseDecoder

#
SameSite

pub(all) enum SameSite {
Strict
Lax
SameSiteNone
}

SameSite attribute
impl Eq for SameSite

#
SameSite::to_string

fn SameSite::to_string(self : SameSite) -> String

#
SetCookie

pub(all) struct SetCookie {
name : String
value : String
expires : HttpDate?
max_age : Int?
domain : String?
path : String?
secure : Bool
http_only : Bool
same_site : SameSite?
}

Set-Cookie header
impl Eq for SetCookie

#
SetCookie::domain

fn SetCookie::domain(self : SetCookie) -> String?

#
SetCookie::expires

fn SetCookie::expires(self : SetCookie) -> HttpDate?

#
SetCookie::http_only

fn SetCookie::http_only(self : SetCookie) -> Bool

#
SetCookie::max_age

fn SetCookie::max_age(self : SetCookie) -> Int?

#
SetCookie::name

fn SetCookie::name(self : SetCookie) -> String

#
SetCookie::new

fn SetCookie::new(name : String, value : String) -> Result[SetCookie, CookieError]

#
SetCookie::parse

fn SetCookie::parse(input : String) -> Result[SetCookie, CookieError]

#
SetCookie::path

fn SetCookie::path(self : SetCookie) -> String?

#
SetCookie::same_site

fn SetCookie::same_site(self : SetCookie) -> SameSite?

#
SetCookie::secure

fn SetCookie::secure(self : SetCookie) -> Bool

#
SetCookie::to_string

fn SetCookie::to_string(self : SetCookie) -> String

#
SetCookie::value

fn SetCookie::value(self : SetCookie) -> String

#
SetCookie::with_domain

fn SetCookie::with_domain(self : SetCookie, domain : String) -> SetCookie

#
SetCookie::with_expires

fn SetCookie::with_expires(self : SetCookie, expires : HttpDate) -> SetCookie

#
SetCookie::with_http_only

fn SetCookie::with_http_only(self : SetCookie, http_only : Bool) -> SetCookie

#
SetCookie::with_max_age

fn SetCookie::with_max_age(self : SetCookie, max_age : Int) -> SetCookie

#
SetCookie::with_path

fn SetCookie::with_path(self : SetCookie, path : String) -> SetCookie

#
SetCookie::with_same_site

fn SetCookie::with_same_site(self : SetCookie, same_site : SameSite) -> SetCookie

#
SetCookie::with_secure

fn SetCookie::with_secure(self : SetCookie, secure : Bool) -> SetCookie

#
Trailer

pub(all) struct Trailer {
fields : Array[String]
}

Trailer header (RFC 9112 Section 7.1.2)
impl Eq for Trailer
impl Show for Trailer

#
Trailer::fields

fn Trailer::fields(self : Trailer) -> Array[String]

#
Trailer::parse

fn Trailer::parse(input : String) -> Result[Trailer, TrailerError]

#
Trailer::to_string

fn Trailer::to_string(self : Trailer) -> String

#
TrailerError

pub(all) enum TrailerError {
Empty
InvalidFormat
InvalidFieldName
}

Trailer header parsing errors (RFC 9112 Section 7.1.2)
impl Eq for TrailerError

#
Upgrade

pub(all) struct Upgrade {
protocols : Array[Protocol]
}

Upgrade header (RFC 9110 Section 7.8)
impl Eq for Upgrade
impl Show for Upgrade

#
Upgrade::has_protocol

fn Upgrade::has_protocol(self : Upgrade, protocol : String) -> Bool

#
Upgrade::parse

fn Upgrade::parse(input : String) -> Result[Upgrade, UpgradeError]

#
Upgrade::protocols

fn Upgrade::protocols(self : Upgrade) -> Array[Protocol]

#
Upgrade::to_string

fn Upgrade::to_string(self : Upgrade) -> String

#
UpgradeError

pub(all) enum UpgradeError {
Empty
InvalidFormat
InvalidProtocol
InvalidVersion
}

Upgrade header parsing errors (RFC 9110 Section 7.8)
impl Eq for UpgradeError

#
Uri

pub(all) struct Uri {
source : String
scheme_end : Int?
authority_start : Int?
authority_end : Int?
host_end : Int?
port : Int?
path_start : Int
path_end : Int
query_start : Int?
query_end : Int?
fragment_start : Int?
}

Parsed URI (RFC 3986 Section 3)

URI structure: foo://example.com:8042/over/there?name=ferret#nose _/ _/_/ ___/ _/ | | | | | scheme authority path query fragment
impl Eq for Uri
impl Show for Uri

#
Uri::as_str

fn Uri::as_str(self : Uri) -> String

#
Uri::authority

fn Uri::authority(self : Uri) -> String?

#
Uri::fragment

fn Uri::fragment(self : Uri) -> String?

#
Uri::host

fn Uri::host(self : Uri) -> String?

#
Uri::is_absolute

fn Uri::is_absolute(self : Uri) -> Bool

#
Uri::is_relative

fn Uri::is_relative(self : Uri) -> Bool

#
Uri::origin_form

fn Uri::origin_form(self : Uri) -> String

#
Uri::parse

fn Uri::parse(input : String) -> Result[Uri, UriError]

#
Uri::path

fn Uri::path(self : Uri) -> String

#
Uri::port

fn Uri::port(self : Uri) -> Int?

#
Uri::query

fn Uri::query(self : Uri) -> String?

#
Uri::scheme

fn Uri::scheme(self : Uri) -> String?

#
Uri::to_string

fn Uri::to_string(self : Uri) -> String

#
UriError

pub(all) enum UriError {
Empty
InvalidPercentEncoding
InvalidPort
InvalidCharacter
InvalidScheme
InvalidHost
InvalidUtf8
}

URI parsing errors (RFC 3986)
impl Eq for UriError
impl Show for UriError

#
Vary

pub(all) struct Vary {
any : Bool
fields : Array[String]
}

Vary header (RFC 9110 Section 12.5.5)
impl Eq for Vary
impl Show for Vary

#
Vary::fields

fn Vary::fields(self : Vary) -> Array[String]

#
Vary::is_any

fn Vary::is_any(self : Vary) -> Bool

#
Vary::parse

fn Vary::parse(input : String) -> Result[Vary, VaryError]

#
Vary::to_string

fn Vary::to_string(self : Vary) -> String

#
VaryError

pub(all) enum VaryError {
Empty
InvalidFormat
InvalidFieldName
}

Vary header parsing errors (RFC 9110 Section 12.5.5)
impl Eq for VaryError
impl Show for VaryError

#
WantContentDigest

pub(all) struct WantContentDigest {
preferences : Array[DigestPreference]
}

Want-Content-Digest header (RFC 9530)

#
WantContentDigest::get

fn WantContentDigest::get(self : WantContentDigest, algorithm : String) -> Int?

#
WantContentDigest::parse

fn WantContentDigest::parse(input : String) -> Result[WantContentDigest, DigestFieldsError]

#
WantContentDigest::preferences

#
WantContentDigest::to_string

fn WantContentDigest::to_string(self : WantContentDigest) -> String

#
WantReprDigest

pub(all) struct WantReprDigest {
preferences : Array[DigestPreference]
}

Want-Repr-Digest header (RFC 9530)

#
WantReprDigest::get

fn WantReprDigest::get(self : WantReprDigest, algorithm : String) -> Int?

#
WantReprDigest::parse

fn WantReprDigest::parse(input : String) -> Result[WantReprDigest, DigestFieldsError]

#
WantReprDigest::preferences

#
WantReprDigest::to_string

fn WantReprDigest::to_string(self : WantReprDigest) -> String

#
WwwAuthenticate

pub(all) struct WwwAuthenticate {
realm : String
charset : String?
}

WWW-Authenticate header (Basic)

#
WwwAuthenticate::basic

fn WwwAuthenticate::basic(realm : String) -> WwwAuthenticate

#
WwwAuthenticate::charset

fn WwwAuthenticate::charset(self : WwwAuthenticate) -> String?

#
WwwAuthenticate::parse

fn WwwAuthenticate::parse(input : String) -> Result[WwwAuthenticate, AuthError]

#
WwwAuthenticate::realm

fn WwwAuthenticate::realm(self : WwwAuthenticate) -> String

#
WwwAuthenticate::to_header_value

fn WwwAuthenticate::to_header_value(self : WwwAuthenticate) -> String

#
WwwAuthenticate::to_string

fn WwwAuthenticate::to_string(self : WwwAuthenticate) -> String

#
WwwAuthenticate::with_charset

fn WwwAuthenticate::with_charset(self : WwwAuthenticate, charset : String) -> WwwAuthenticate

#
encode_chunk

fn encode_chunk(data : Array[Byte]) -> Array[Byte]

Encode a single chunk of chunked transfer encoding

#
encode_chunks

fn encode_chunks(chunks : Array[Array[Byte]]) -> Array[Byte]

Encode multiple chunks of chunked transfer encoding

#
encode_request

fn encode_request(request : Request) -> Array[Byte]

Encode an HTTP request to bytes

#
encode_request_headers

fn encode_request_headers(request : Request) -> Array[Byte]

Encode only the headers part of an HTTP request

#
encode_response

fn encode_response(response : Response) -> Array[Byte]

Encode an HTTP response to bytes

#
encode_response_headers

fn encode_response_headers(response : Response) -> Array[Byte]

Encode only the headers part of an HTTP response

#
parse_etag_list

fn parse_etag_list(input : String) -> Result[ETagList, ETagError]

#
percent_decode

fn percent_decode(input : String) -> Result[String, UriError]

#
percent_decode_bytes

fn percent_decode_bytes(input : String) -> Result[Array[Int], UriError]

#
percent_encode

fn percent_encode(input : String) -> String

#
percent_encode_path

fn percent_encode_path(input : String) -> String

#
percent_encode_query

fn percent_encode_query(input : String) -> String

#
rg_parse_u64

fn rg_parse_u64(s : String) -> UInt64?

#
rg_u64_to_string

fn rg_u64_to_string(n : UInt64) -> String