Library guide · API index and notation
This page is generated from the bundled library in this checkout. Signatures and adjacent source comments are reproduced below; the linked guide explains usage, storage, failures, and platform support.
import "std/http"
Names used in signatures
Unqualified names denote this package’s types (including other source files in the same package), language built-ins, or generic parameters such as T. Qualified names use the import aliases below. These aliases belong to the library source; import a dependency yourself to use its alias in your program.
| Alias | Package | Source file |
|---|---|---|
ascii |
core/ascii |
http.dodo |
bytes |
core/bytes |
http.dodo |
io |
std/io |
http.dodo |
mem |
core/mem |
http.dodo |
net |
std/net |
http.dodo |
ptr |
core/ptr |
http.dodo |
ErrorKind
Enum · Source
Allocation-free HTTP/1.1, RFC 9110/9112. This module owns no device, clock, scheduler, or cryptography. Every output view is tied to caller-owned bytes.
pub enum ErrorKind {
InvalidUri, InvalidMethod, InvalidStatus, InvalidHeader, InvalidStartLine,
InvalidFraming, InvalidChunk, ForbiddenTrailer, HeaderLimit, BodyLimit,
BufferFull, UnexpectedEof, InvalidState, Poisoned, OutOfBounds
}
Error
Struct · Source
pub struct Error {
pub kind: ErrorKind
pub position: usize
}
Error.format
Function · Source
Only fixed kind names and numeric metadata; never input or native messages.
pub fn format<F>(&self, output: &mut F) -> void!io.Error
failure
Function · Source
pub fn failure(kind: ErrorKind, position: usize) -> Error
equal_ascii
Function · Source
pub fn equal_ascii(a: &[u8], b: &[u8]) -> bool
token_byte
Function · Source
pub fn token_byte(c: u8) -> bool
valid_token
Function · Source
pub fn valid_token(data: &[u8]) -> bool
valid_value
Function · Source
pub fn valid_value(data: &[u8]) -> bool
Method
Struct · Source
pub struct Method {
// Private implementation fields omitted.
}
Method.new
Function · Source
pub fn new(value: &[u8]) -> Method!Error from(value)
Method.bytes
Function · Source
pub fn bytes(&self) -> &[u8]
Method.idempotent
Function · Source
pub fn idempotent(&self) -> bool
Status
Struct · Source
pub struct Status {
pub code: u16
}
Status.new
Function · Source
pub fn new(code: u16) -> Status!Error
Status.informational
Function · Source
pub fn informational(&self) -> bool
valid_authority
Function · Source
Validate an HTTP authority without name resolution. IPv6 brackets delimit colons; reg-name bytes retain percent escapes. Scoped IP literals are not supported in HTTP authorities.
pub fn valid_authority(data: &[u8], require_port: bool) -> bool
Uri
Struct · Source
URI syntax is ASCII; percent escapes are validated but never decoded here. Userinfo and fragments are rejected for HTTP request-targets and origins.
pub struct Uri {
// Private implementation fields omitted.
}
Uri.parse
Function · Source
pub fn parse(data: &[u8]) -> Uri!Error from(data)
Uri.bytes
Function · Source
pub fn bytes(&self) -> &[u8]
Uri.scheme
Function · Source
pub fn scheme(&self) -> &[u8]
Uri.authority
Function · Source
pub fn authority(&self) -> &[u8]
Uri.path
Function · Source
pub fn path(&self) -> &[u8]
Uri.query
Function · Source
pub fn query(&self) -> &[u8]
Uri.secure
Function · Source
pub fn secure(&self) -> bool
Uri.same_origin
Function · Source
pub fn same_origin(&self, other: &Uri) -> bool
Header
Struct · Source
pub struct Header {
pub name: &[u8]
pub value: &[u8]
}
BodyKind
Enum · Source
pub enum BodyKind {
None, Length, Chunked, Close
}
Body
Struct · Source
pub struct Body {
pub kind: BodyKind
pub length: u64
}
Body.empty
Function · Source
pub fn empty() -> Body
Body.sized
Function · Source
pub fn sized(length: u64) -> Body
Body.streaming
Function · Source
pub fn streaming() -> Body
Request
Struct · Source
pub struct Request {
pub method: &[u8]
pub target: &[u8]
pub headers: &[Header]
pub body: Body
}
Response
Struct · Source
pub struct Response {
pub status: u16
pub reason: &[u8]
pub headers: &[Header]
pub body: Body
}
Role
Enum · Source
pub enum Role {
Request, Response
}
Limits
Struct · Source
pub struct Limits {
pub header_bytes: usize
pub header_fields: usize
pub body_bytes: u64
pub chunk_line_bytes: usize
pub trailer_bytes: usize
pub trailer_fields: usize
}
Limits.defaults
Function · Source
pub fn defaults() -> Limits
EventKind
Enum · Source
pub enum EventKind {
NeedInput, StartLine, Header, HeadersComplete, Body, Trailer, Informational, Complete, Upgrade
}
Event
Struct · Source
pub struct Event {
pub kind: EventKind
// Always advance by consumed. Body's offset/length index this feed input;
// header name/value index Parser.field(). No event retains input pointers.
pub consumed: usize
pub offset: usize
pub length: usize
pub name_offset: usize
pub name_length: usize
pub value_offset: usize
pub value_length: usize
}
forbidden_trailer
Function · Source
pub fn forbidden_trailer(name: &[u8]) -> bool
ParserState
Struct · Source
States: 0 start, 1 headers, 2 length, 3 chunk-size, 4 chunk-data, 5 chunk CR, 6 chunk LF, 7 trailers, 8 close-body, 9 complete-pending, 10 complete, 11 upgrade, 12 informational-pending, 13 restart, 255 poisoned.
pub struct ParserState {
// Private implementation fields omitted.
}
ParserState.new
Function · Source
pub fn new(role: Role, limits: Limits) -> ParserState
Parser
Struct · Source
pub struct Parser {
// Private implementation fields omitted.
}
Parser.new
Function · Source
pub fn new(role: Role, workspace: &mut[u8], limits: Limits) -> Parser from(workspace)
Parser.resume
Function · Source
The state owns no buffers. Resume with the same workspace contents; offsets remain bounds checked if the caller supplies smaller storage.
pub fn resume(workspace: &mut[u8], state: ParserState) -> Parser!Error from(workspace)
Parser.take_state
Function · Source
pub fn take_state(&mut self) -> ParserState
Parser.suspend
Function · Source
pub fn suspend(self) -> ParserState
Parser.method
Function · Source
pub fn method(&self) -> &[u8]
Parser.target
Function · Source
pub fn target(&self) -> &[u8]
Parser.status
Function · Source
pub fn status(&self) -> u16
Parser.body_kind
Function · Source
pub fn body_kind(&self) -> BodyKind
Parser.body_remaining
Function · Source
pub fn body_remaining(&self) -> u64
Parser.body_received
Function · Source
pub fn body_received(&self) -> u64
Parser.field
Function · Source
pub fn field(&self, offset: usize, length: usize) -> &[u8]!Error from(self)
Parser.reusable
Function · Source
pub fn reusable(&self) -> bool
Parser.poisoned
Function · Source
pub fn poisoned(&self) -> bool
Parser.expect_head
Function · Source
pub fn expect_head(&mut self, value: bool)
Parser.expect_connect
Function · Source
pub fn expect_connect(&mut self, value: bool)
Parser.poison
Function · Source
pub fn poison(&mut self)
Parser.next_message
Function · Source
pub fn next_message(&mut self) -> void!Error
Parser.eof
Function · Source
pub fn eof(&mut self) -> Event!Error
Parser.feed
Function · Source
pub fn feed(&mut self, input: &[u8]) -> Event!Error
write_request
Function · Source
Caller must not transmit a buffer when serialization fails. Input headers cannot supply framing fields: Body is their sole authority.
pub fn write_request(request: &Request, destination: &mut[u8]) -> usize!Error
write_response
Function · Source
pub fn write_response(response: &Response, destination: &mut[u8]) -> usize!Error
Encoded
Struct · Source
pub struct Encoded {
pub consumed: usize
pub written: usize
}
Sender
Struct · Source
pub struct Sender {
// Private implementation fields omitted.
}
Sender.new
Function · Source
pub fn new(body: Body) -> Sender
Sender.complete
Function · Source
pub fn complete(&self) -> bool
Sender.poisoned
Function · Source
pub fn poisoned(&self) -> bool
Sender.poison
Function · Source
pub fn poison(&mut self)
Sender.frame
Function · Source
pub fn frame(&mut self, input: &[u8], destination: &mut[u8]) -> Encoded!Error
Sender.direct
Function · Source
Length/close-delimited bytes may go straight to a transport. Chunked bodies still require frame(). Validate before exposing any source bytes.
pub fn direct(&mut self, count: usize) -> bool!Error
Sender.advance_direct
Function · Source
pub fn advance_direct(&mut self, count: usize) -> void!Error
Sender.finish
Function · Source
pub fn finish(&mut self, trailers: &[Header], destination: &mut[u8]) -> usize!Error
RedirectPolicy
Struct · Source
Policy decisions take explicit facts; no replay, redirect, time, or socket side effects occur inside the portable package.
pub struct RedirectPolicy {
pub max_hops: usize
pub allow_https_downgrade: bool
}
RedirectPolicy.defaults
Function · Source
pub fn defaults() -> RedirectPolicy
RedirectPolicy.permits
Function · Source
pub fn permits(&self, source: &Uri, target: &Uri, hops: usize, replayable: bool) -> bool
RetryPolicy
Struct · Source
pub struct RetryPolicy {
pub max_attempts: usize
}
RetryPolicy.defaults
Function · Source
pub fn defaults() -> RetryPolicy
RetryPolicy.permits
Function · Source
pub fn permits(&self, method: &Method, attempts: usize, replayable: bool, response_started: bool) -> bool
sensitive_header
Function · Source
pub fn sensitive_header(name: &[u8]) -> bool
forward_header
Function · Source
Recompute Host and strip credentials whenever the origin changes. Proxy credentials are always proxy-scoped; never forward them to origin servers.
pub fn forward_header(name: &[u8], same_origin: bool, to_proxy: bool) -> bool