52#ifndef __NILOREA_HTTP2_SERVER_HEADER
53#define __NILOREA_HTTP2_SERVER_HEADER
66#define N_H2_SRV_MAX_HEADERS 128
68#define N_H2_SRV_MAX_BODY (16 * 1024 * 1024)
70#define N_H2_SRV_MAX_STREAMS 128
72#define N_H2_SRV_READ_CHUNK 16384
76#define N_H2_ERR_NO_ERROR 0x0
77#define N_H2_ERR_PROTOCOL_ERROR 0x1
78#define N_H2_ERR_INTERNAL_ERROR 0x2
79#define N_H2_ERR_FLOW_CONTROL_ERROR 0x3
80#define N_H2_ERR_SETTINGS_TIMEOUT 0x4
81#define N_H2_ERR_STREAM_CLOSED 0x5
82#define N_H2_ERR_FRAME_SIZE_ERROR 0x6
83#define N_H2_ERR_REFUSED_STREAM 0x7
84#define N_H2_ERR_CANCEL 0x8
85#define N_H2_ERR_COMPRESSION_ERROR 0x9
86#define N_H2_ERR_CONNECT_ERROR 0xa
87#define N_H2_ERR_ENHANCE_YOUR_CALM 0xb
88#define N_H2_ERR_INADEQUATE_SECURITY 0xc
89#define N_H2_ERR_HTTP_1_1_REQUIRED 0xd
HTTP/2 (RFC 7540) wire framing plus HPACK header compression (RFC 7541).
one HPACK header field; after a decode both strings are owned (heap)
const char * authority
the :authority pseudo-header, or NULL when absent
size_t nheaders
number of header fields
uint32_t stream_id
the stream the request arrived on
ssize_t(* n_h2_srv_read_fn)(void *io, void *buf, size_t len)
read up to len bytes into buf: returns the bytes read (>0), 0 on a clean end of stream,...
int n_http2_server_run(N_H2_SERVER *srv, n_h2_srv_request_cb cb, void *user_data)
serve the connection until it ends
int n_http2_server_handshake(N_H2_SERVER *srv)
read and validate the client connection preface, then send ours
int n_http2_server_respond(N_H2_SERVER *srv, uint32_t stream_id, const N_H2_HEADER *headers, size_t nheaders, const unsigned char *body, size_t body_len)
write a complete response on a stream (HEADERS then DATA, END_STREAM)
ssize_t(* n_h2_srv_write_fn)(void *io, const void *buf, size_t len)
write exactly len bytes from buf: returns len on success, -1 on error
size_t n_http2_server_request_count(const N_H2_SERVER *srv)
the number of requests delivered to the callback so far
int n_http2_server_goaway(N_H2_SERVER *srv, uint32_t error_code)
send GOAWAY, naming the last stream we processed
const char * method
the :method pseudo-header, or NULL when absent
N_H2_HEADER * headers
the decoded header fields, pseudo-headers included
size_t body_len
the body length in bytes
N_H2_SERVER * n_http2_server_new(void *io, n_h2_srv_read_fn rd, n_h2_srv_write_fn wr)
create a server connection over the given I/O callbacks
void n_http2_server_free(N_H2_SERVER **srv)
free a server connection and NULL the caller's pointer
const char * scheme
the :scheme pseudo-header, or NULL when absent
int(* n_h2_srv_request_cb)(void *user_data, N_H2_SERVER *srv, const N_H2_REQUEST *req)
called with each complete request; answer it with n_http2_server_respond() (or n_http2_server_rst_str...
const char * path
the :path pseudo-header, or NULL when absent
const char * n_http2_server_error(const N_H2_SERVER *srv)
the reason the connection failed, or NULL when none was recorded
const unsigned char * body
the request body, or NULL when there is none
int n_http2_server_rst_stream(N_H2_SERVER *srv, uint32_t stream_id, uint32_t error_code)
abort one stream with RST_STREAM
one complete request received on a stream; every pointer is owned by the server and valid only for th...