http2_server

Generated by tinox doc

tinox.core.http2_server, split out of the bundled stdlib as a standalone tinox-central package.

ModuleVersionGroup
hpack1.2.0tinox.core
http_server1.1.1tinox.core

Hello server

import tinox.core.http2_server

class Main
{
    fnc main() -> Int32
    {
        const server: Http2Server = Http2Server::new(8443)
        server.get("/hello", ctx => {
            ctx.response.text("Hello over HTTP/2!")
        })
        server.listen()
        return 0
    }
}

class Http2Conn

* State for one HTTP/2 client connection. * Holds all active streams and both encoder/decoder HPACK tables.

Fields

handleInt64
streamsMap<String, Http2Stream>
recvDynTableHpackDynTable
sendDynTableHpackDynTable
peerMaxFrameSizeInt64
peerInitWindowSizeInt64
lastStreamIdInt64

Methods

fn new(handle: Int64) → Http2Conn

class Http2Error

Methods

fn NO_ERROR() → Int64
fn PROTOCOL_ERROR() → Int64
fn INTERNAL_ERROR() → Int64
fn FLOW_CONTROL_ERROR() → Int64
fn STREAM_CLOSED() → Int64
fn FRAME_SIZE_ERROR() → Int64
fn REFUSED_STREAM() → Int64
fn CANCEL() → Int64
fn COMPRESSION_ERROR() → Int64

class Http2Flags

Methods

fn END_STREAM() → Int64
fn END_HEADERS() → Int64
fn PADDED() → Int64
fn PRIORITY() → Int64
fn ACK() → Int64

class Http2Frame

* An HTTP/2 frame with its 9-byte fixed header fields and payload. * The payload is a list of raw byte values (Int64, each 0–255).

Fields

lengthInt64
typeInt64
flagsInt64
streamIdInt64
payloadList<Int64>

Methods

fn new(type: Int64, flags: Int64, streamId: Int64, payload: List<Int64>) → Http2Frame

class Http2FrameType

Methods

fn DATA() → Int64
fn HEADERS() → Int64
fn PRIORITY() → Int64
fn RST_STREAM() → Int64
fn SETTINGS() → Int64
fn PUSH_PROMISE() → Int64
fn PING() → Int64
fn GOAWAY() → Int64
fn WINDOW_UPDATE() → Int64
fn CONTINUATION() → Int64

fn httpServerReadRawBytes(fd: Int64, count: Int64) → String

fn tinoxBytesToString(bytes: List<Int64>) → String

fn tinoxSecurityGuard(ctx: HttpContext, routeExists: Int64) → Int64

class Http2Server

* HTTP/2 server with a fluent route-registration API identical to HttpServer. * * Handles the full HTTP/2 connection lifecycle per RFC 7540: * connection preface validation, SETTINGS exchange, binary frame I/O, * HPACK decoding for requests and encoding for responses, * multi-stream multiplexing, and graceful GOAWAY shutdown.

Fields

portInt64
routesList<Route>
middlewareList<fnc(HttpContext) -> Bool>
socketHandleInt64
runningBool

Methods

fn new(port: Int64) → Http2Server
fn get(path: String, handler: fnc(HttpContext) -> Nothing) → Http2Server
fn post(path: String, handler: fnc(HttpContext) -> Nothing) → Http2Server
fn put(path: String, handler: fnc(HttpContext) -> Nothing) → Http2Server
fn patch(path: String, handler: fnc(HttpContext) -> Nothing) → Http2Server
fn delete(path: String, handler: fnc(HttpContext) -> Nothing) → Http2Server
fn use(mware: fnc(HttpContext) -> Bool) → Http2Server
fn stop() → Nothing
fn listen() → Nothing
* Starts listening and enters the connection accept loop. * Each accepted connection is handled synchronously (blocking per connection).
fn readBytes(wire: Int64, count: Int64) → List<Int64>
fn sendBytes(wire: Int64, bytes: List<Int64>) → Nothing
fn appendBytes(dest: List<Int64>, src: List<Int64>) → Nothing
fn readFrame(conn: Http2Conn) → Http2Frame
fn writeFrame(conn: Http2Conn, frame: Http2Frame) → Nothing
fn sendServerSettings(conn: Http2Conn) → Nothing
fn sendSettingsAck(conn: Http2Conn) → Nothing
fn sendPong(conn: Http2Conn, pingPayload: List<Int64>) → Nothing
fn sendGoaway(conn: Http2Conn, errorCode: Int64) → Nothing
fn sendRstStream(conn: Http2Conn, streamId: Int64, errorCode: Int64) → Nothing
fn processSettings(conn: Http2Conn, frame: Http2Frame) → Nothing
fn processHeaders(conn: Http2Conn, frame: Http2Frame) → Nothing
fn processContinuation(conn: Http2Conn, frame: Http2Frame) → Nothing
fn processData(conn: Http2Conn, frame: Http2Frame) → Nothing
fn dispatchStream(conn: Http2Conn, stream: Http2Stream) → Nothing
* Decodes a completed stream into an HttpContext, runs middleware and * route matching, then sends the HEADERS + DATA response frames.
fn sendResponse(conn: Http2Conn, streamId: Int64, response: HttpResponse) → Nothing
* Encodes an HttpResponse as HTTP/2 HEADERS + DATA frames and sends them. * HEADERS carries the :status pseudo-header plus all response headers. * DATA carries the body (omitted for empty bodies; END_STREAM on HEADERS instead).
fn handleConnection(fd: Int64) → Nothing
* Manages a single HTTP/2 connection from preface validation through GOAWAY. * * Steps: * 1. Read and validate the 24-byte client connection preface * 2. Send server SETTINGS * 3. Enter the frame-processing loop: * - SETTINGS → update peer params, send ACK * - HEADERS → accumulate header block, dispatch when END_HEADERS + END_STREAM * - CONTINUATION → append to header block, dispatch when END_HEADERS * - DATA → accumulate body, dispatch on END_STREAM * - PING → echo back with ACK flag * - RST_STREAM → mark stream closed * - GOAWAY → graceful shutdown * - WINDOW_UPDATE → acknowledged but not tracked (basic flow control) * 4. Send GOAWAY and close the connection
fn runMiddleware(ctx: HttpContext) → Bool
fn routeExistsFor(ctx: HttpContext) → Int64
fn matchRoute(ctx: HttpContext) → Bool

class Http2Settings

Methods

fn HEADER_TABLE_SIZE() → Int64
fn ENABLE_PUSH() → Int64
fn MAX_CONCURRENT_STREAMS() → Int64
fn INITIAL_WINDOW_SIZE() → Int64
fn MAX_FRAME_SIZE() → Int64
fn MAX_HEADER_LIST_SIZE() → Int64

class Http2Stream

* Per-stream state for an HTTP/2 connection. * * Accumulates the HPACK-encoded header block across one or more * HEADERS/CONTINUATION frames, and body bytes from DATA frames.

Fields

idInt64
stateString "open" | "half_closed_remote" | "closed"
headerBlockList<Int64>
bodyList<Int64>
endStreamBool
expectingContinuationBool

Methods

fn new(id: Int64) → Http2Stream