Skip to main content

cturtle/btweb

include "cturtle/btweb";

Types​

HpackDecoder​

Object

FieldTypeWritableDescription
dynamic_tablearray<HttpHeader>yes
dynamic_sizeintyes
max_sizeintyes
allowed_max_sizeintyes
huffman_leftarray<int>yes
huffman_rightarray<int>yes
huffman_symbolarray<int>yes

HttpHeader​

Object

FieldTypeWritableDescription
namestringyes
valuestringyes

HttpRequest​

Object

FieldTypeWritableDescription
methodstringyes
targetstringyes
pathstringyes
querystringyes
versionstringyes
protocolstringyes
headersarray<HttpHeader>yes
bodybufferyes
stream_idintyes

fn header(string name) -> string

HttpResponse​

Object

FieldTypeWritableDescription
statusintyes
headersarray<HttpHeader>yes
bodybufferyes
committedboolyes

header​

fn header(string name, string value) -> HttpResponse

append_header​

fn append_header(string name, string value) -> HttpResponse

write​

fn write(buffer bytes) -> HttpResponse

write_string​

fn write_string(string text) -> HttpResponse

text​

fn text(int status, string text) -> HttpResponse

json​

fn json(int status, string json) -> HttpResponse

redirect​

fn redirect(int status, string location) -> HttpResponse

HttpContext​

Object

FieldTypeWritableDescription
requestHttpRequestyes
responseHttpResponseyes
paramsmap<string, string>yes
statemap<string, string>yes

param infallible​

infallible fn param(string name) -> string

HttpRoute​

Object

FieldTypeWritableDescription
methodstringyes
patternstringyes
handlerHttpHandleryes
middleware_stackarray<HttpMiddleware>yes
orderintyes

middleware infallible​

infallible fn middleware(HttpMiddleware value) -> HttpRoute

HttpRouter​

Object

FieldTypeWritableDescription
routesarray<HttpRoute>yes
exact_bucket_idsmap<string, int>yes
exact_route_bucketsarray<array<HttpRoute>>yes
dynamic_routesarray<HttpRoute>yes
middleware_stackarray<HttpMiddleware>yes
not_foundHttpHandleryes
next_orderintyes

middleware infallible​

infallible fn middleware(HttpMiddleware value) -> HttpRouter

route infallible​

infallible fn route(string method, string pattern, HttpHandler handler) -> HttpRoute

get infallible​

infallible fn get(string pattern, HttpHandler handler) -> HttpRoute

head infallible​

infallible fn head(string pattern, HttpHandler handler) -> HttpRoute

post infallible​

infallible fn post(string pattern, HttpHandler handler) -> HttpRoute

put infallible​

infallible fn put(string pattern, HttpHandler handler) -> HttpRoute

patch infallible​

infallible fn patch(string pattern, HttpHandler handler) -> HttpRoute

delete infallible​

infallible fn delete(string pattern, HttpHandler handler) -> HttpRoute

options infallible​

infallible fn options(string pattern, HttpHandler handler) -> HttpRoute

dispatch​

fn dispatch(HttpContext context)

HttpConnection​

Object

FieldTypeWritableDescription
peersocketyes
inputbufferyes
startintyes
endintyes
limitintyes
header_timeoutfloatyes
cached_hoststringyes
cached_targetstringyes
http1_consumedintyes
http1_close_after_responseboolyes
http1_host_countintyes
http1_content_lengthintyes
http1_transfer_encoding_countintyes
http1_transfer_encoding_chunkedboolyes
http1_expect_continueboolyes
http1_expect_unsupportedboolyes
http1_connection_closeboolyes
http1_connection_keep_aliveboolyes

HttpConnectionLimiter​

Object

FieldTypeWritableDescription
lockMutexyes
activeintyes
max_activeintyes

try_acquire​

fn try_acquire() -> bool

release​

fn release()

HttpServer​

Object

FieldTypeWritableDescription
routerHttpRouteryes
hoststringyes
servicestringyes
familyintyes
backlogintyes
max_header_bytesintyes
max_body_bytesintyes
max_connectionsintyes
header_timeoutfloatyes

listen​

fn listen() -> socket

serve​

fn serve()

serve_connections​

fn serve_connections(int count)

HttpStaticFiles​

Object

FieldTypeWritableDescription
rootstringyes
index_filestringyes

serve​

fn serve(HttpContext context, string relative)

handle​

fn handle(HttpContext context)

HttpStaticIndex​

Object

FieldTypeWritableDescription
filesHttpStaticFilesyes

handle​

fn handle(HttpContext context)

Interfaces​

HttpHandler​

Interface

handle​

fn handle(HttpContext context)

HttpMiddleware​

Interface

handle​

fn handle(HttpContext context, HttpHandler next)

Functions​

hpack_decoder​

fn hpack_decoder(int allowed_max_size) -> HpackDecoder

hpack_static_names infallible​

infallible fn hpack_static_names() -> array<string>

hpack_static_values infallible​

infallible fn hpack_static_values() -> array<string>

hpack_decode_block​

fn hpack_decode_block(
HpackDecoder decoder,
buffer bytes,
int offset,
int count,
int max_header_list_size) -> array<HttpHeader>

http_router infallible​

infallible fn http_router() -> HttpRouter

http_request infallible​

infallible fn http_request(
string method,
string target,
string path,
string query,
string version,
string protocol,
array<HttpHeader> headers,
buffer body,
int stream_id) -> HttpRequest

http_context infallible​

infallible fn http_context(HttpRequest request) -> HttpContext

http_validate_header​

fn http_validate_header(string name, string value)

http_ascii_lower​

fn http_ascii_lower(string text) -> string

http_header_get​

fn http_header_get(array<HttpHeader> headers, string name) -> string

http_has_token​

fn http_has_token(string value, string token) -> bool

http1_valid_token_range​

fn http1_valid_token_range(buffer bytes, int offset, int count) -> bool

http1_valid_value_range​

fn http1_valid_value_range(buffer bytes, int offset, int count) -> bool

http1_header_kind​

fn http1_header_kind(buffer bytes, int offset, int count) -> int

http1_method​

fn http1_method(buffer bytes, int offset, int count) -> string

http1_content_length​

fn http1_content_length(array<HttpHeader> headers) -> int

http1_parse_headers​

fn http1_parse_headers(
HttpConnection connection,
int first_line_end,
int header_end,
HttpRequest request)

http1_parse_request_only​

fn http1_parse_request_only(
HttpConnection connection,
int max_header_bytes,
int max_body_bytes) -> HttpRequest

http1_write_response_into​

fn http1_write_response_into(
socket peer,
HttpRequest request,
HttpResponse response,
bool close_after,
buffer output)

http_connection​

fn http_connection(socket peer, int limit, float header_timeout) -> HttpConnection

http_connection_compact​

fn http_connection_compact(HttpConnection connection)

http_connection_read_more​

fn http_connection_read_more(HttpConnection connection) -> int

http_connection_find_or_read​

fn http_connection_find_or_read(
HttpConnection connection,
string needle,
int offset,
int maximum_end,
int too_large_status) -> int

http_send_all​

fn http_send_all(socket peer, buffer bytes, int offset, int count)

http_copy_range​

fn http_copy_range(buffer source, int offset, int count, buffer destination)

http_read_u24​

fn http_read_u24(buffer bytes, int offset) -> int

http_read_u31​

fn http_read_u31(buffer bytes, int offset) -> int

http_read_u32​

fn http_read_u32(buffer bytes, int offset) -> int

http_push_u24​

fn http_push_u24(buffer bytes, int value)

http_push_u32​

fn http_push_u32(buffer bytes, int value)

http_server infallible​

infallible fn http_server(
HttpRouter router,
string host,
string service) -> HttpServer

http_server_connection​

fn http_server_connection(HttpServer server, socket peer)

http_static_content_type​

fn http_static_content_type(string path) -> string

http_static_safe_relative_path​

fn http_static_safe_relative_path(string path) -> bool

http_static_files infallible​

infallible fn http_static_files(string root) -> HttpStaticFiles

http_static_index infallible​

infallible fn http_static_index(HttpStaticFiles files) -> HttpStaticIndex