mizchi/x/http does not have a README file

    HttpError

    pub suberror HttpError {
    NetworkError(String)
    InvalidUrl(String)
    TimeoutError
    NotSupported
    } derive(
    Debug
    )

    impl Show for HttpError

    HttpError::output

    fn HttpError::output(self : HttpError, logger : &Logger) -> Unit

    HttpError::to_repr

    automatically derived

    HttpError::to_string

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

    Default implementation for Show::to_string, uses a StringBuilder

    Addr

    pub(all) struct Addr {
    text : String
    port : Int
    }

    Client

    pub struct Client {
    inner :
    ClientConnection

    // private fields
    }

    Client::close

    fn Client::close(self : Client) -> Unit

    Client::drop

    async fn Client::drop(self : Client, len : Int) -> Int

    Client::drop_all

    async fn Client::drop_all(self : Client) -> Int64 raise
    ReaderError

    Drop all remaining content from a binary reader, until EOF is reached.

    Client::drop_exactly

    async fn Client::drop_exactly(self : Client, len : Int) -> Unit raise
    ReaderError

    reader.drop_exactly(len) drops exactly len bytes from the reader. drop_exactly waits until enough bytes are available. If EOF is reached before enough data is dropped, UnexpectedEof will be raised.

    Client::end_request

    async fn Client::end_request(self : Client) -> Response raise HttpError

    Client::enter_passthrough_mode

    async fn Client::enter_passthrough_mode(self : Client) -> Unit raise HttpError

    Client::flush

    async fn Client::flush(self : Client) -> Unit raise HttpError

    Client::get

    async fn Client::get(self : Client, path : String, extra_headers? : Map[String, String], body? : &
    Data
    ) -> Response raise HttpError

    Client::new

    async fn Client::new(url : String, headers? : Map[String, String], proxy? : Client, verify? : Bool, trust? :
    TrustedRoot
    ) -> Client raise HttpError

    Client::peek

    async fn Client::peek(self : Client) -> BytesView? raise
    ReaderError

    reader.peek() fetches and returns a chunk of data from the reader. The returned data will not get consumed from the reader: other reader API can still fetch them later.

    The chunk returned by reader.peek() is a copy-free slice of the reader's internal buffer, and its content will be overwritten by subsequent reader operations. So caller of peek MUST NOT use the returned slice after any other BinaryReader operation is invoked on the same reader. If the data need to be kept persistent, copy it via .to_owned().

    The returned chunk will contain at least one byte. If EOF is reached before any data is fetched, None will be returned.

    reader.peek() is cancellation safe as long as the underlying reader implementation is cancellation safe. When reader.peek() is cancelled, no data will be lost.

    Client::peek_at_least

    async fn Client::peek_at_least(self : Client, min_len : Int) -> BytesView raise
    ReaderError

    reader.peek_at_least(min_len) fetches and returns a chunk containing at least min_len bytes without consuming it. The returned chunk may be larger than min_len.

    The returned view is valid only until another operation is invoked on the same reader. Use .to_owned() to keep the data persistently.

    If EOF is reached before enough data is fetched, UnexpectedEof will be raised. Any shorter trailing data remains buffered and can be fetched by a later reader operation.

    reader.peek_at_least() is cancellation safe as long as the underlying reader implementation is cancellation safe. When it is cancelled, no data will be lost.

    Client::peek_exactly

    async fn Client::peek_exactly(self : Client, len : Int) -> BytesView raise
    ReaderError

    reader.peek_exactly(len) fetches exactly len bytes from the reader. It will wait until enough number of bytes is available. The returned data will not get consumed from the reader: other reader API can still fetch them later.

    The chunk returned by reader.peek_exactly() is a copy-free slice of the reader's internal buffer, and its content will be overwritten by subsequent reader operations. So caller of peek MUST NOT use the returned slice after any other BinaryReader operation is invoked on the same reader. If the data need to be kept persistent, copy it via .to_owned().

    If EOF is reached before enough data is read, UnexpectedEof will be raised. In this case remaining data remain buffered, and can be fetched by other reader operations later.

    reader.peek_exactly() is cancellation safe as long as the underlying reader implementation is cancellation safe. When reader.peek_exactly() is cancelled, no data will be lost.

    Client::peek_until

    async fn Client::peek_until(self : Client, pattern : BytesView, include_delimiter? : Bool) -> BytesView? raise
    ReaderError

    reader.peek_until(pat, include_delimiter? : Bool = false) fetches content from reader until the byte string pat is found in the reader stream. The returned data will not get consumed from the reader: other reader API can still fetch them later.

    The chunk returned by reader.peek_until() is a copy-free slice of the reader's internal buffer, and its content will be overwritten by subsequent reader operations. So caller of peek MUST NOT use the returned slice after any other BinaryReader operation is invoked on the same reader. If the data need to be kept persistent, copy it via .to_owned().

    If pat is found in the input stream, content before that occurrence is returned. If include_delimiter is true, pat itself is included at the end of the result. The returned data may be empty in this case if include_delimiter is false.

    EOF is implicitly treated as a delimiter by reader.peek_until(). If pat is not found in the input stream when EOF is reached, trailing data before EOF will be returned (or None if there is no trailing data). In this case, the returned data contains no trailing delimiter even if include_delimiter=true. This can be used to detect the presence of trailing delimiter in the input stream.

    reader.peek_until() is cancellation safe as long as the underlying reader implementation is cancellation safe. When reader.peek_until() is cancelled, no data will be lost.

    Client::post

    async fn Client::post(self : Client, path : String, body : &
    Data
    , extra_headers? : Map[String, String]) -> Response raise HttpError

    Client::put

    async fn Client::put(self : Client, path : String, body : &
    Data
    , extra_headers? : Map[String, String]) -> Response raise HttpError

    Client::read

    async fn Client::read(self : Client, buf : FixedArray[Byte], offset? : Int, max_len? : Int) -> Int

    Client::read_all

    async fn Client::read_all(self : Client) -> &
    Data

    Client::read_at_least

    async fn Client::read_at_least(self : Client, min_len : Int) -> Bytes raise
    ReaderError

    reader.read_at_least(min_len) fetches and returns an owned chunk containing at least min_len bytes. The returned chunk may be larger than min_len.

    If EOF is reached before enough data is fetched, UnexpectedEof will be raised. Any shorter trailing data remains buffered and can be fetched through another reader operation later.

    reader.read_at_least() is cancellation safe as long as the underlying reader implementation is cancellation safe. When it is cancelled, no data will be lost.

    Client::read_exactly

    async fn Client::read_exactly(self : Client, len : Int) -> Bytes raise
    ReaderError

    reader.read_exactly(len) reads exactly len bytes from the reader. It will wait until enough number of bytes is available. If EOF is reached before enough data is read, UnexpectedEof will be raised.

    Client::read_into

    async fn Client::read_into(self : Client, dst : MutArrayView[Byte]) -> Int raise
    ReaderError

    reader.read_into(dst) reads at most dst.length() bytes from the reader into dst. The number of bytes actually read is returned. Note that the return value may be smaller than dst.length() if not enough data is immediately available. If EOF is reached and no more data is available, zero will be returned.

    Client::read_some

    async fn Client::read_some(self : Client, max_len? : Int) -> Bytes?

    Client::read_until

    async fn Client::read_until(self : Client, sep : StringView) -> String?

    Client::request

    async fn Client::request(self : Client, meth : RequestMethod, path : StringView, extra_headers? : Map[String, String]) -> Unit raise HttpError

    Client::skip_response_body

    async fn Client::skip_response_body(self : Client) -> Unit raise HttpError

    Client::write

    async fn Client::write(self : Client, data : &
    Data
    ) -> Unit

    Client::write_once

    async fn Client::write_once(self : Client, buf : Bytes, offset~ : Int, len~ : Int) -> Int

    Client::write_reader

    async fn Client::write_reader(self : Client, reader : &
    BinaryReader
    ) -> Unit

    writer.write_reader(reader) continuously reads from input stream reader and writes all its content to writer until EOF is reached.

    write_reader only raises two kinds of error: @io.ReaderError from the reader, or @io.WriterError from the writer.
    pub struct Cookie {
    name : String
    value : String
    path : String?
    expires_raw : String?
    max_age : Int64?
    domain : String?
    secure : Bool
    http_only : Bool
    extensions : Array[String]
    } derive(
    Debug
    )

    Cookie::Cookie

    #alias(new, deprecated="`new` is deprecated, use `Cookie` instead")
    fn Cookie::Cookie(name : String, value : String, path? : String, expires_raw? : String, max_age? : Int64, domain? : String, secure? : Bool, http_only? : Bool, extensions? : Array[String]) -> Cookie

    Cookie::to_repr

    automatically derived

    NativeServer

    pub struct NativeServer {
    // private fields
    }

    A native HTTP listener that can bound the request head before parsing.

    NativeServer::close

    fn NativeServer::close(self : NativeServer) -> Unit

    NativeServer::new

    async fn NativeServer::new(host? : String, port? : Int, headers? : Map[String, String], dual_stack? : Bool, reuse_addr? : Bool, max_request_head_bytes? : Int, max_request_body_bytes? : Int, request_timeout_ms? : Int, keep_alive_timeout_ms? : Int, headers_timeout_ms? : Int) -> NativeServer raise HttpError

    Start a native HTTP listener with an on-wire request-head limit. The limit includes the request line and terminating empty line. A non-positive value disables it.

    NativeServer::port

    fn NativeServer::port(self : NativeServer) -> Int

    NativeServer::run_forever

    async fn NativeServer::run_forever(self : NativeServer, handle : async (Request, &
    BinaryReader
    , ServerConnection) -> Unit, allow_failure? : Bool, max_connections? : Int) -> Unit raise HttpError

    Request

    pub(all) struct Request {
    meth : RequestMethod
    path : String
    headers : Map[String, String]
    }

    RequestMethod

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

    RequestMethod::compare

    automatically derived

    RequestMethod::equal

    automatically derived

    RequestMethod::hash

    fn RequestMethod::hash(self : RequestMethod) -> Int
    automatically derived

    RequestMethod::hash_combine

    fn RequestMethod::hash_combine(RequestMethod, Hasher) -> Unit
    automatically derived

    RequestMethod::not_equal

    fn RequestMethod::not_equal(x : RequestMethod, y : RequestMethod) -> Bool
    automatically derived

    RequestMethod::op_ge

    fn RequestMethod::op_ge(x : RequestMethod, y : RequestMethod) -> Bool
    automatically derived

    RequestMethod::op_gt

    fn RequestMethod::op_gt(x : RequestMethod, y : RequestMethod) -> Bool
    automatically derived

    RequestMethod::op_le

    fn RequestMethod::op_le(x : RequestMethod, y : RequestMethod) -> Bool
    automatically derived

    RequestMethod::op_lt

    fn RequestMethod::op_lt(x : RequestMethod, y : RequestMethod) -> Bool
    automatically derived

    RequestMethod::output

    fn RequestMethod::output(self : RequestMethod, logger : &Logger) -> Unit

    RequestMethod::to_repr

    automatically derived

    RequestMethod::to_string

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

    Default implementation for Show::to_string, uses a StringBuilder

    Response

    pub(all) struct Response {
    code : Int
    reason : String
    headers : Map[String, String]
    cookies : Array[Cookie]
    }

    Server

    pub struct Server {
    inner :
    Server

    // private fields
    }

    Server::accept

    async fn Server::accept(self : Server) -> (ServerConnection, Addr) raise HttpError

    Server::addr

    fn Server::addr(self : Server) -> Addr

    Server::close

    fn Server::close(self : Server) -> Unit

    Server::close_graceful

    async fn Server::close_graceful(self : Server, timeout_ms? : Int) -> Unit raise HttpError

    Server::new

    async fn Server::new(host? : String, port? : Int, headers? : Map[String, String], dual_stack? : Bool, reuse_addr? : Bool, max_request_body_bytes? : Int, request_timeout_ms? : Int, keep_alive_timeout_ms? : Int, headers_timeout_ms? : Int, accept_queue_limit? : Int, trust_proxy? : Bool) -> Server raise HttpError

    Positive Native limits bound decoded request body bytes, body reading time, and header reading time. On a reused connection the shorter configured header or keep-alive deadline applies while waiting for the next headers.

    Server::port

    fn Server::port(self : Server) -> Int

    Server::run_forever

    async fn Server::run_forever(self : Server, f : async (Request, &
    BinaryReader
    , ServerConnection) -> Unit, allow_failure? : Bool, max_connections? : Int) -> Unit raise HttpError

    ServerConnection

    pub struct ServerConnection {
    inner :
    ServerConnection

    // private fields
    }

    ServerConnection::client_addr

    fn ServerConnection::client_addr(self : ServerConnection) -> Addr

    ServerConnection::close

    fn ServerConnection::close(self : ServerConnection) -> Unit

    ServerConnection::drop

    async fn ServerConnection::drop(self : ServerConnection, len : Int) -> Int

    ServerConnection::drop_all

    Drop all remaining content from a binary reader, until EOF is reached.

    ServerConnection::drop_exactly

    async fn ServerConnection::drop_exactly(self : ServerConnection, len : Int) -> Unit raise
    ReaderError

    reader.drop_exactly(len) drops exactly len bytes from the reader. drop_exactly waits until enough bytes are available. If EOF is reached before enough data is dropped, UnexpectedEof will be raised.

    ServerConnection::end_response

    async fn ServerConnection::end_response(self : ServerConnection) -> Unit raise HttpError

    ServerConnection::enter_passthrough_mode

    async fn ServerConnection::enter_passthrough_mode(self : ServerConnection) -> Unit raise HttpError

    ServerConnection::flush

    async fn ServerConnection::flush(self : ServerConnection) -> Unit raise HttpError

    ServerConnection::peek

    reader.peek() fetches and returns a chunk of data from the reader. The returned data will not get consumed from the reader: other reader API can still fetch them later.

    The chunk returned by reader.peek() is a copy-free slice of the reader's internal buffer, and its content will be overwritten by subsequent reader operations. So caller of peek MUST NOT use the returned slice after any other BinaryReader operation is invoked on the same reader. If the data need to be kept persistent, copy it via .to_owned().

    The returned chunk will contain at least one byte. If EOF is reached before any data is fetched, None will be returned.

    reader.peek() is cancellation safe as long as the underlying reader implementation is cancellation safe. When reader.peek() is cancelled, no data will be lost.

    ServerConnection::peek_at_least

    async fn ServerConnection::peek_at_least(self : ServerConnection, min_len : Int) -> BytesView raise
    ReaderError

    reader.peek_at_least(min_len) fetches and returns a chunk containing at least min_len bytes without consuming it. The returned chunk may be larger than min_len.

    The returned view is valid only until another operation is invoked on the same reader. Use .to_owned() to keep the data persistently.

    If EOF is reached before enough data is fetched, UnexpectedEof will be raised. Any shorter trailing data remains buffered and can be fetched by a later reader operation.

    reader.peek_at_least() is cancellation safe as long as the underlying reader implementation is cancellation safe. When it is cancelled, no data will be lost.

    ServerConnection::peek_exactly

    async fn ServerConnection::peek_exactly(self : ServerConnection, len : Int) -> BytesView raise
    ReaderError

    reader.peek_exactly(len) fetches exactly len bytes from the reader. It will wait until enough number of bytes is available. The returned data will not get consumed from the reader: other reader API can still fetch them later.

    The chunk returned by reader.peek_exactly() is a copy-free slice of the reader's internal buffer, and its content will be overwritten by subsequent reader operations. So caller of peek MUST NOT use the returned slice after any other BinaryReader operation is invoked on the same reader. If the data need to be kept persistent, copy it via .to_owned().

    If EOF is reached before enough data is read, UnexpectedEof will be raised. In this case remaining data remain buffered, and can be fetched by other reader operations later.

    reader.peek_exactly() is cancellation safe as long as the underlying reader implementation is cancellation safe. When reader.peek_exactly() is cancelled, no data will be lost.

    ServerConnection::peek_until

    async fn ServerConnection::peek_until(self : ServerConnection, pattern : BytesView, include_delimiter? : Bool) -> BytesView? raise
    ReaderError

    reader.peek_until(pat, include_delimiter? : Bool = false) fetches content from reader until the byte string pat is found in the reader stream. The returned data will not get consumed from the reader: other reader API can still fetch them later.

    The chunk returned by reader.peek_until() is a copy-free slice of the reader's internal buffer, and its content will be overwritten by subsequent reader operations. So caller of peek MUST NOT use the returned slice after any other BinaryReader operation is invoked on the same reader. If the data need to be kept persistent, copy it via .to_owned().

    If pat is found in the input stream, content before that occurrence is returned. If include_delimiter is true, pat itself is included at the end of the result. The returned data may be empty in this case if include_delimiter is false.

    EOF is implicitly treated as a delimiter by reader.peek_until(). If pat is not found in the input stream when EOF is reached, trailing data before EOF will be returned (or None if there is no trailing data). In this case, the returned data contains no trailing delimiter even if include_delimiter=true. This can be used to detect the presence of trailing delimiter in the input stream.

    reader.peek_until() is cancellation safe as long as the underlying reader implementation is cancellation safe. When reader.peek_until() is cancelled, no data will be lost.

    ServerConnection::read

    async fn ServerConnection::read(self : ServerConnection, buf : FixedArray[Byte], offset? : Int, max_len? : Int) -> Int

    ServerConnection::read_all

    ServerConnection::read_at_least

    async fn ServerConnection::read_at_least(self : ServerConnection, min_len : Int) -> Bytes raise
    ReaderError

    reader.read_at_least(min_len) fetches and returns an owned chunk containing at least min_len bytes. The returned chunk may be larger than min_len.

    If EOF is reached before enough data is fetched, UnexpectedEof will be raised. Any shorter trailing data remains buffered and can be fetched through another reader operation later.

    reader.read_at_least() is cancellation safe as long as the underlying reader implementation is cancellation safe. When it is cancelled, no data will be lost.

    ServerConnection::read_exactly

    async fn ServerConnection::read_exactly(self : ServerConnection, len : Int) -> Bytes raise
    ReaderError

    reader.read_exactly(len) reads exactly len bytes from the reader. It will wait until enough number of bytes is available. If EOF is reached before enough data is read, UnexpectedEof will be raised.

    ServerConnection::read_into

    reader.read_into(dst) reads at most dst.length() bytes from the reader into dst. The number of bytes actually read is returned. Note that the return value may be smaller than dst.length() if not enough data is immediately available. If EOF is reached and no more data is available, zero will be returned.

    ServerConnection::read_request

    async fn ServerConnection::read_request(self : ServerConnection) -> Request raise HttpError

    ServerConnection::read_some

    async fn ServerConnection::read_some(self : ServerConnection, max_len? : Int) -> Bytes?

    ServerConnection::read_until

    async fn ServerConnection::read_until(self : ServerConnection, sep : StringView) -> String?

    ServerConnection::send_response

    async fn ServerConnection::send_response(self : ServerConnection, code : Int, reason : String, extra_headers? : Map[String, String], cookies? : Array[Cookie]) -> Unit raise HttpError

    ServerConnection::skip_request_body

    async fn ServerConnection::skip_request_body(self : ServerConnection) -> Unit raise HttpError

    ServerConnection::upstream_request

    Recover the core header for a request read from this connection.

    ServerConnection::write

    async fn ServerConnection::write(self : ServerConnection, data : &
    Data
    ) -> Unit

    ServerConnection::write_once

    async fn ServerConnection::write_once(self : ServerConnection, buf : Bytes, offset~ : Int, len~ : Int) -> Int

    ServerConnection::write_reader

    writer.write_reader(reader) continuously reads from input stream reader and writes all its content to writer until EOF is reached.

    write_reader only raises two kinds of error: @io.ReaderError from the reader, or @io.WriterError from the writer.

    Stream

    Stream::close

    fn Stream::close(self : Stream) -> Unit

    Stream::read_all

    async fn Stream::read_all(self : Stream) -> Bytes raise HttpError

    Stream::read_some

    async fn Stream::read_some(self : Stream) -> Bytes? raise HttpError

    get

    async fn get(url : String, headers? : Map[String, String], body? : &
    Data
    , proxy? : Client) -> (Response, &
    Data
    ) raise HttpError

    get_stream

    async fn get_stream(url : String, headers? : Map[String, String], body? : &
    Data
    , proxy? : Client) -> (Response, Client) raise HttpError

    post

    async fn post(url : String, body : &
    Data
    , headers? : Map[String, String], proxy? : Client) -> (Response, &
    Data
    ) raise HttpError

    post_stream

    async fn post_stream(url : String, headers? : Map[String, String], proxy? : Client) -> Client raise HttpError

    put

    async fn put(url : String, body : &
    Data
    , headers? : Map[String, String], proxy? : Client) -> (Response, &
    Data
    ) raise HttpError

    put_stream

    async fn put_stream(url : String, headers? : Map[String, String], proxy? : Client) -> Client raise HttpError