api

types.ch

Declarations in types.ch

1 declarationshttp

Declarations

Public only
http#
Publicnamespace
namespace http
===== HTTP utilities and types =====
HeaderMap#
Publicstruct
struct HeaderMap { var headers : vector<pair<string, string>> }
make#
PublicfunctionConstructor
func make() : HeaderMap
empty#
Publicfunction
func empty(self : &HeaderMap) : bool
print#
Publicfunction
func print(self : &HeaderMap) : void
insert#
Publicfunction
func insert(self : &HeaderMap, k : string, v : string) : void
insert_view#
Publicfunction
func insert_view(self : &HeaderMap, k : &string_view, v : &string_view) : void
get#
Publicfunction
func get(self : &HeaderMap, name : *char) : Option<string>
Case-insensitive header lookup. Returns Some(value) if present.
get_view#
Publicfunction
func get_view(self : &HeaderMap, name : &string_view) : string_view
delete#
function
func delete(self : *HeaderMap) : void
QueryMap#
Publicstruct
struct QueryMap { var pairs : vector<pair<string, string>> }
make#
PublicfunctionConstructor
func make() : QueryMap
make_from_qs#
PublicfunctionConstructor
func make_from_qs(qs : &string_view) : QueryMap
get#
Publicfunction
func get(self : &QueryMap, key : &string_view) : string_view
delete#
function
func delete(self : *QueryMap) : void
strcasecmp#
Publicfunction
func strcasecmp(a : *char, b : *char) : int
helper: simple ASCII case-insensitive strcmp
Body#
Publicstruct
struct Body { var sock : Socket var buf : *Buffer var remaining : isize var chunked : bool var timeout_secs : long var max_body : usize var closed : bool var cur_chunk_left : usize var seen_total : usize var owns_buf : bool var tls_ctx : *SSLContext }
Body: lazy reader for request body. Does NOT close the socket by itself.
empty_make#
PublicfunctionConstructor
func empty_make() : Body
TLS context for secure reads (null = plain socket)
destruct#
Publicfunction
func destruct(self : &Body) : void
make_body#
Publicfunction
func make_body(sock : Socket, buf_ptr : *Buffer, content_len : isize, chunked : bool, timeout_secs : long, max_body : usize, owns : bool) : Body
construct body from request metadata
body_recv#
function
func body_recv(b : *Body, dst : *u8, cap : usize) : int
low-level recv helper that honors timeout and returns <=0 on error/timeout
copy_from_buffer#
function
func copy_from_buffer(b : *Body, dst : *u8, want : usize) : usize
Helper: copy up to `want` bytes from the already-read buffer into dst, returning copied count.
read#
PublicfunctionExtension
func read(b : &Body, dst : *u8, cap : usize) : int
PUBLIC: read up to `cap` bytes into dst.
read_to_string#
PublicfunctionExtension
func read_to_string(b : &Body) : Option<string>
read all remaining body into a string
read_exact#
PublicfunctionExtension
func read_exact(b : &Body, n : usize) : Option<string>
read exactly `n` bytes
drain#
PublicfunctionExtension
func drain(b : &Body) : bool
drain remaining body
close#
PublicfunctionExtension
func close(b : &Body) : void
close resources
socket#
PublicfunctionExtension
func socket(b : &Body) : Socket
Access to the underlying socket for consumers that need to inspect or
close_socket#
PublicfunctionExtension
func close_socket(b : &Body) : void
Close the underlying socket immediately. Subsequent reads return 0.
is_chunked#
PublicfunctionExtension
func is_chunked(b : &Body) : bool
True if the body uses Transfer-Encoding: chunked.
content_length#
PublicfunctionExtension
func content_length(b : &Body) : isize
Remaining body bytes when Content-Length was present, or -1 when the
Request#
Publicstruct
struct Request { var method : string var path : string var query : QueryMap var proto : string var headers : HeaderMap var body_len : usize var remote : string var body : Body var route_params : vector<pair<string, string>> }
constructor#
PublicfunctionConstructor
func constructor() : Request
delete#
function
func delete(self : *Request) : void
Response#
Publicstruct
struct Response { var status : uint var status_text : string var proto : string var headers : HeaderMap var body_len : usize var body : Body }
constructor#
PublicfunctionConstructor
func constructor() : Response
delete#
function
func delete(self : *Response) : void