unmbt/webstd/http does not have a README file

    StreamError

    pub(all) suberror StreamError {
    StreamReadError(String)
    StreamAborted(String)
    PayloadTooLarge(Int64)
    StreamAlreadyConsumed
    } derive(Eq,
    Debug
    )

    流式读写与载荷上限标准错误(防断连静默与 OOM)

    WsError

    pub(all) suberror WsError {
    Closed(code~ : WsCloseCode, reason~ : String)
    ProtocolFailure(String)
    IoFailure(String)
    } derive(Eq,
    Debug
    )

    Body

    pub(all) enum Body {
    Empty
    Bytes(Bytes)
    Text(String)
    Stream(ByteStream)
    }

    Body::is_empty

    fn Body::is_empty(self : Body) -> Bool

    Body::read_all_bytes

    async fn Body::read_all_bytes(self : Body, max_bytes? : Int64) -> Bytes

    Body::read_all_text

    async fn Body::read_all_text(self : Body, max_bytes? : Int64) -> String

    ByteStream

    pub struct ByteStream {
    next_chunk : async () -> Bytes?
    cancel : (String) -> Unit
    }

    异步流式载荷抽象(语言级 async 协程签名,生产代码零 core/async 依赖,四目标均可编译)

    ByteStream::ByteStream

    fn ByteStream::ByteStream(next_chunk~ : async () -> Bytes?, cancel? : (String) -> Unit) -> ByteStream

    ByteStream::from_chunks

    fn ByteStream::from_chunks(chunks : Array[Bytes]) -> ByteStream

    pub(all) struct Cookie {
    name : String
    value : String
    path : String?
    domain : String?
    max_age : Int64?
    expires : String?
    http_only : Bool
    secure : Bool
    same_site : SameSite?
    partitioned : Bool
    } derive(Eq,
    Debug
    )

    一等公民结构化 Cookie(支撑 ciallo-native 1:1 零重解析映射至 @std_http.Cookie,及 ciallo-js append("set-cookie");序列化时严格拒绝含 \r / \n / ; 控制字符以防头注入)

    Cookie::Cookie

    fn Cookie::Cookie(name : String, value : String, options? : CookieOptions) -> Cookie

    fn Cookie::parse_set_cookie(line : StringView) -> Cookie?

    仅在业务向 Response.headers 手工塞入裸 "set-cookie" 字符串时供 ciallo-native 兜底解析
    fn Cookie::to_set_cookie_header(self : Cookie) -> String

    序列化为标准 Set-Cookie 头值;若含非法控制字符(\r / \n / \0)或 ; 注入字符,则严格拒绝并返回空字符串 ""

    CookieOptions

    pub(all) struct CookieOptions {
    path : String?
    domain : String?
    max_age : Int64?
    expires : String?
    http_only : Bool
    secure : Bool
    same_site : SameSite?
    partitioned : Bool
    } derive(Eq,
    Debug
    )

    CookieOptions::CookieOptions

    fn CookieOptions::CookieOptions(path? : String, domain? : String, max_age? : Int64, expires? : String, http_only? : Bool, secure? : Bool, same_site? : SameSite, partitioned? : Bool) -> CookieOptions

    FormData

    pub struct FormData {
    entries : Array[(String, FormEntry)]
    } derive(Eq,
    Debug
    )

    FormData::FormData

    fn FormData::FormData(entries? : Array[(String, FormEntry)]) -> FormData

    FormData::append_file

    fn FormData::append_file(self : FormData, name : StringView, filename~ : String, content_type? : String, bytes~ : Bytes) -> Unit

    FormData::append_text

    fn FormData::append_text(self : FormData, name : StringView, value : StringView) -> Unit

    FormData::encode_multipart

    fn FormData::encode_multipart(self : FormData, boundary? : String) -> (String, Bytes)

    FormData::encode_urlencoded

    fn FormData::encode_urlencoded(self : FormData) -> String

    FormData::entries

    fn FormData::entries(self : FormData) -> Array[(String, FormEntry)]

    FormData::get

    fn FormData::get(self : FormData, name : StringView) -> FormEntry?

    FormData::get_all

    fn FormData::get_all(self : FormData, name : StringView) -> Array[FormEntry]

    FormData::get_text

    fn FormData::get_text(self : FormData, name : StringView) -> String?

    FormData::parse_multipart

    fn FormData::parse_multipart(content_type : StringView, body : BytesView) -> FormData raise StreamError

    FormData::parse_urlencoded

    fn FormData::parse_urlencoded(input : StringView) -> FormData raise
    UrlError

    FormEntry

    pub(all) enum FormEntry {
    Text(String)
    File(filename~ : String, content_type~ : String, bytes~ : Bytes)
    } derive(Eq,
    Debug
    )

    Headers

    pub struct Headers {
    // private fields
    } derive(Eq,
    Debug
    )

    大小写不敏感的多值 HTTP 头集合(保留同键多值顺序)

    Headers::Headers

    fn Headers::Headers(entries? : Array[(String, String)]) -> Headers

    Headers::append

    fn Headers::append(self : Headers, name : StringView, value : StringView) -> Unit

    Headers::clone

    fn Headers::clone(self : Headers) -> Headers

    Headers::entries

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

    Headers::get

    fn Headers::get(self : Headers, name : StringView) -> String?

    Headers::get_all

    fn Headers::get_all(self : Headers, name : StringView) -> Array[String]

    fn Headers::get_set_cookie(self : Headers) -> Array[String]

    对齐 Fetch 标准 Headers.getSetCookie()

    Headers::has

    fn Headers::has(self : Headers, name : StringView) -> Bool

    Headers::remove

    fn Headers::remove(self : Headers, name : StringView) -> Unit

    Headers::set

    fn Headers::set(self : Headers, name : StringView, value : StringView) -> Unit

    Method

    pub(all) enum Method {
    Get
    Head
    Post
    Put
    Patch
    Delete
    Options
    Trace
    Connect
    Custom(String)
    } derive(Eq, Hash,
    Debug
    )

    Method::as_str

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

    Method::parse

    fn Method::parse(raw : StringView) -> Method

    NdjsonDecoder

    pub struct NdjsonDecoder {
    // private fields
    }

    纯同步增量 NDJSON 解码状态机(四目标全通测试)

    NdjsonDecoder::NdjsonDecoder

    fn NdjsonDecoder::NdjsonDecoder() -> NdjsonDecoder

    NdjsonDecoder::feed

    fn NdjsonDecoder::feed(self : NdjsonDecoder, chunk : BytesView) -> Array[
    Json
    ] raise StreamError

    NdjsonDecoder::finish

    Request

    pub(all) struct Request {
    meth : Method
    url :
    Url

    headers : Headers
    body : Body
    }

    Request::Request

    fn Request::Request(meth~ : Method, url~ : StringView, headers? : Headers, body? : Body) -> Request raise
    UrlError

    Request::header

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

    Response

    pub(all) struct Response {
    status : Int
    headers : Headers
    cookies : Array[Cookie]
    body : Body
    normalized : Bool
    }

    Response::Response

    fn Response::Response(status? : Int, headers? : Headers, cookies? : Array[Cookie], body? : Body, normalized? : Bool) -> Response

    Response::bytes

    fn Response::bytes(data : Bytes, status? : Int, content_type? : StringView, headers? : Headers) -> Response

    Response::empty

    fn Response::empty(status? : Int, headers? : Headers) -> Response

    Response::json

    fn Response::json(value :
    Json
    , status? : Int, headers? : Headers) -> Response

    Response::ndjson

    fn Response::ndjson(next_item : async () ->
    Json
    ?, status? : Int, headers? : Headers) -> Response

    Response::redirect

    fn Response::redirect(location : StringView, status? : Int) -> Response

    fn Response::set_cookie(self : Response, cookie : Cookie) -> Response

    Response::sse

    fn Response::sse(events : ByteStream, status? : Int, headers? : Headers) -> Response

    Response::sse_events

    fn Response::sse_events(next_event : async () -> SseEvent?, status? : Int, headers? : Headers) -> Response

    Response::text

    fn Response::text(text : StringView, status? : Int, headers? : Headers) -> Response

    fn Response::with_cookie(self : Response, name : StringView, value : StringView, options? : CookieOptions) -> Response

    SameSite

    pub(all) enum SameSite {
    Lax
    Strict
    None
    } derive(Eq,
    Debug
    )

    SseDecoder

    pub struct SseDecoder {
    // private fields
    }

    纯同步增量 SSE 解码状态机(处理跨 chunk 拆包与多字节 UTF-8,四目标全通测试)

    SseDecoder::SseDecoder

    fn SseDecoder::SseDecoder() -> SseDecoder

    SseDecoder::feed

    fn SseDecoder::feed(self : SseDecoder, chunk : BytesView) -> Array[SseEvent]

    SseDecoder::finish

    fn SseDecoder::finish(self : SseDecoder) -> Array[SseEvent]

    SseEvent

    pub(all) struct SseEvent {
    id : String?
    event : String?
    data : String
    retry_ms : Int?
    } derive(Eq,
    Debug
    )

    一等公民 Server-Sent Events(SSE)结构化事件帧、泛型强类型事件帧与四目标纯同步增量解码器

    SseEvent::SseEvent

    fn SseEvent::SseEvent(data~ : String, id? : String, event? : String, retry_ms? : Int) -> SseEvent

    SseEvent::encode

    fn SseEvent::encode(self : SseEvent) -> Bytes

    TransformStream

    pub struct TransformStream {
    transform : (Bytes) -> Array[Bytes] raise StreamError
    flush : () -> Array[Bytes] raise StreamError
    }

    Pure 4-target WinterTC TransformStream transformer over ByteStream chunks.

    TransformStream::TransformStream

    fn TransformStream::TransformStream(transform~ : (Bytes) -> Array[Bytes] raise StreamError, flush? : () -> Array[Bytes] raise StreamError) -> TransformStream

    TransformStream::pipe

    Pipe an async ByteStream through this TransformStream lazily with backpressure.

    TransformStream::process_chunks

    fn TransformStream::process_chunks(self : TransformStream, chunks : Array[Bytes]) -> Array[Bytes] raise StreamError

    Synchronous chunk pipeline helper usable on all 4 targets (including wasm-gc).

    TypedSseEvent

    pub(all) struct TypedSseEvent[T] {
    id : String?
    event : String?
    data : T
    retry_ms : Int?
    } derive(Eq,
    Debug
    )

    TypedSseEvent::TypedSseEvent

    fn[T] TypedSseEvent::TypedSseEvent(data~ : T, id? : String, event? : String, retry_ms? : Int) -> TypedSseEvent[T]

    WsCloseCode

    pub(all) enum WsCloseCode {
    Normal
    GoingAway
    ProtocolError
    UnsupportedData
    InvalidPayload
    PolicyViolation
    MessageTooBig
    InternalError
    Custom(Int)
    } derive(Eq,
    Debug
    )

    WsCloseCode::code

    fn WsCloseCode::code(self : WsCloseCode) -> Int

    WsCloseCode::from_code

    fn WsCloseCode::from_code(code : Int) -> WsCloseCode

    WsMessage

    pub(all) enum WsMessage {
    Text(String)
    Binary(Bytes)
    Ping(Bytes)
    Pong(Bytes)
    Close(code~ : WsCloseCode, reason~ : String)
    } derive(Eq,
    Debug
    )

    fn format_set_cookie(name : StringView, value : StringView, options? : CookieOptions) -> String

    parse_cookies

    fn parse_cookies(header_value : StringView) -> Map[String, String]

    status_reason

    fn status_reason(code : Int) -> String

    RFC 9110 标准 HTTP 状态短语(未知状态码回退 "",供 ciallo-native send_response 零分配调用)