cturtle/btweb
include "cturtle/btweb";
Types
HpackDecoder
Object
| Field | Type | Writable | Description |
|---|---|---|---|
dynamic_table | array<HttpHeader> | yes | |
dynamic_size | int | yes | |
max_size | int | yes | |
allowed_max_size | int | yes | |
huffman_left | array<int> | yes | |
huffman_right | array<int> | yes | |
huffman_symbol | array<int> | yes |
HttpHeader
Object
| Field | Type | Writable | Description |
|---|---|---|---|
name | string | yes | |
value | string | yes |
HttpRequest
Object
| Field | Type | Writable | Description |
|---|---|---|---|
method | string | yes | |
target | string | yes | |
path | string | yes | |
query | string | yes | |
version | string | yes | |
protocol | string | yes | |
headers | array<HttpHeader> | yes | |
body | buffer | yes | |
stream_id | int | yes |
header
fn header(string name) -> string
HttpResponse
Object
| Field | Type | Writable | Description |
|---|---|---|---|
status | int | yes | |
headers | array<HttpHeader> | yes | |
body | buffer | yes | |
committed | bool | yes |
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
| Field | Type | Writable | Description |
|---|---|---|---|
request | HttpRequest | yes | |
response | HttpResponse | yes | |
params | map<string, string> | yes | |
state | map<string, string> | yes |
param infallible
infallible fn param(string name) -> string
HttpRoute
Object
| Field | Type | Writable | Description |
|---|---|---|---|
method | string | yes | |
pattern | string | yes | |
handler | HttpHandler | yes | |
middleware_stack | array<HttpMiddleware> | yes | |
order | int | yes |
middleware infallible
infallible fn middleware(HttpMiddleware value) -> HttpRoute
HttpRouter
Object
| Field | Type | Writable | Description |
|---|---|---|---|
routes | array<HttpRoute> | yes | |
exact_bucket_ids | map<string, int> | yes | |
exact_route_buckets | array<array<HttpRoute>> | yes | |
dynamic_routes | array<HttpRoute> | yes | |
middleware_stack | array<HttpMiddleware> | yes | |
not_found | HttpHandler | yes | |
next_order | int | yes |
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
| Field | Type | Writable | Description |
|---|---|---|---|
peer | socket | yes | |
input | buffer | yes | |
start | int | yes | |
end | int | yes | |
limit | int | yes | |
header_timeout | float | yes | |
cached_host | string | yes | |
cached_target | string | yes | |
http1_consumed | int | yes | |
http1_close_after_response | bool | yes | |
http1_host_count | int | yes | |
http1_content_length | int | yes | |
http1_transfer_encoding_count | int | yes | |
http1_transfer_encoding_chunked | bool | yes | |
http1_expect_continue | bool | yes | |
http1_expect_unsupported | bool | yes | |
http1_connection_close | bool | yes | |
http1_connection_keep_alive | bool | yes |
HttpConnectionLimiter
Object
| Field | Type | Writable | Description |
|---|---|---|---|
lock | Mutex | yes | |
active | int | yes | |
max_active | int | yes |
try_acquire
fn try_acquire() -> bool
release
fn release()
HttpServer
Object
| Field | Type | Writable | Description |
|---|---|---|---|
router | HttpRouter | yes | |
host | string | yes | |
service | string | yes | |
family | int | yes | |
backlog | int | yes | |
max_header_bytes | int | yes | |
max_body_bytes | int | yes | |
max_connections | int | yes | |
header_timeout | float | yes |
listen
fn listen() -> socket
serve
fn serve()
serve_connections
fn serve_connections(int count)
HttpStaticFiles
Object
| Field | Type | Writable | Description |
|---|---|---|---|
root | string | yes | |
index_file | string | yes |
serve
fn serve(HttpContext context, string relative)
handle
fn handle(HttpContext context)
HttpStaticIndex
Object
| Field | Type | Writable | Description |
|---|---|---|---|
files | HttpStaticFiles | yes |
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