6#ifndef __CWIST_HTTP2_H__
7#define __CWIST_HTTP2_H__
39 void *(*on_conn_open)(
void *user_ctx);
47 int (*
on_data)(
void *conn_ctx,
void *stream_ctx,
const unsigned char *data,
size_t len,
50 void (*
on_cancel)(
void *conn_ctx,
void *stream_ctx);
53 int (*
on_poll)(
void *conn_ctx,
void *stream_ctx);
58 void (*
on_close)(
void *conn_ctx,
void *stream_ctx);
93 const unsigned char *data,
size_t data_len);
111 size_t trailer_count);
138int h2_decode_integer(
const unsigned char *buf,
size_t len,
size_t *pos, uint8_t prefix_bits,
144char *
h2_huffman_decode(
const unsigned char *src,
size_t src_len,
size_t *out_len);
167size_t h2_encode_integer(
unsigned char *dst,
size_t dst_cap, uint32_t value, uint8_t prefix_bits);
172size_t h2_encode_string(
unsigned char *dst,
size_t dst_cap,
const char *str);
cwist_h2_async_queue * cwist_h2_async_queue_acquire(cwist_h2_async_queue *q)
Take an additional reference on the queue (for an in-flight cwist_async handle).
int h2_decode_integer(const unsigned char *buf, size_t len, size_t *pos, uint8_t prefix_bits, uint32_t *value)
Decode an HPACK integer.
int cwist_http2_stream_send_trailers(cwist_h2_stream *stream, const cwist_http2_header *trailers, size_t trailer_count)
int cwist_http2_stream_send_headers(cwist_h2_stream *stream, int status, const cwist_http2_header *headers, size_t header_count, int end_stream)
const cwist_http2_static_header * h2_static_header(uint32_t index)
Resolve an HPACK static table index (1-based); NULL when out of range.
struct cwist_h2_stream cwist_h2_stream
size_t h2_encode_string(unsigned char *dst, size_t dst_cap, const char *str)
Encode an HPACK string (literal, non-huffman); 0 when dst is too small.
char * h2_decode_string(const unsigned char *buf, size_t len, size_t *pos)
Decode an HPACK string (literal or huffman).
cwist_error_t cwist_http2_serve_connection_ex(cwist_https_connection *conn, void *user_ctx, cwist_http2_request_handler_func handler, const cwist_http2_stream_hooks *hooks)
Serve one HTTP/2 connection until it closes. Verifies the preface, sends our SETTINGS,...
int cwist_h2_async_queue_enqueue(cwist_h2_async_queue *q, uint32_t stream_id, cwist_http_request *req, cwist_http_response *send, cwist_http_response *res, bool send_owned)
cwist_error_t cwist_http2_serve_connection(cwist_https_connection *conn, void *user_ctx, cwist_http2_request_handler_func handler)
Starts serving an HTTP/2 connection over an established HTTPS session.
void cwist_h2_async_queue_release(cwist_h2_async_queue *q)
Drop a reference on the queue. On the last reference: closes the wake descriptors,...
struct cwist_h2_async_queue cwist_h2_async_queue
void(* cwist_http2_request_handler_func)(void *user_ctx, cwist_http_request *req, cwist_http_response *res)
Callback function type for handling HTTP/2 requests.
int cwist_http2_push_resource(cwist_http_request *req, const char *path, const char *content_type, const unsigned char *data, size_t data_len)
Push a resource to the client over HTTP/2 Server Push.
char * h2_huffman_decode(const unsigned char *src, size_t src_len, size_t *out_len)
Decode an HPACK huffman-encoded string.
size_t h2_encode_integer(unsigned char *dst, size_t dst_cap, uint32_t value, uint8_t prefix_bits)
Encode an HPACK integer; returns bytes written, 0 when dst is too small.
int cwist_http2_stream_send_data(cwist_h2_stream *stream, const unsigned char *data, size_t len)
Send DATA on a hook-taken stream, honoring flow-control credit. Splits data into peer_max_frame_size ...
HTTP Protocol Definitions and Helpers.
HTTPS/TLS wrapper interface.
Integrated error structure used throughout the system.
int(* on_poll)(void *conn_ctx, void *stream_ctx)
int(* on_data)(void *conn_ctx, void *stream_ctx, const unsigned char *data, size_t len, int end_stream)
void(* on_close)(void *conn_ctx, void *stream_ctx)
void(* on_cancel)(void *conn_ctx, void *stream_ctx)
uint64_t(* next_deadline_ms)(void *conn_ctx)
void(* on_conn_close)(void *conn_ctx)
HTTP Response Object. Supports standard string body or Zero-Copy pointer body.