Types (structs, unions and typedefs)
-
typedef ptrdiff_t nghttp3_ssize
nghttp3_ssizeis signed counterpart of size_t.
-
typedef uint64_t nghttp3_tstamp
nghttp3_tstampis a timestamp with nanosecond resolution.UINT64_MAXis an invalid value, and it is often used to indicate that no value is set. This type is available since v1.12.0.
-
typedef uint64_t nghttp3_duration
nghttp3_durationis a period of time in nanosecond resolution.UINT64_MAXis an invalid value, and it is often used to indicate that no value is set. This type is available since v1.12.0.
-
typedef void *(*nghttp3_malloc)(size_t size, void *user_data)
nghttp3_mallocis a custom memory allocator to replace malloc(3). The user_data is thenghttp3_mem.user_data.
-
typedef void (*nghttp3_free)(void *ptr, void *user_data)
nghttp3_freeis a custom memory allocator to replace free(3). The user_data is thenghttp3_mem.user_data.
-
typedef void *(*nghttp3_calloc)(size_t nmemb, size_t size, void *user_data)
nghttp3_callocis a custom memory allocator to replace calloc(3). The user_data is thenghttp3_mem.user_data.
-
typedef void *(*nghttp3_realloc)(void *ptr, size_t size, void *user_data)
nghttp3_reallocis a custom memory allocator to replace realloc(3). The user_data is thenghttp3_mem.user_data.
-
type nghttp3_mem
nghttp3_memis a custom memory allocator functions and user defined pointer. Theuser_datafield is passed to each allocator function. This can be used, for example, to achieve per-session memory pool.In the following example code,
my_malloc,my_free,my_calloc, andmy_reallocare the replacement of the standard allocators malloc(3), free(3), calloc(3) and realloc(3) respectively:void *my_malloc_cb(size_t size, void *user_data) { (void)user_data; return my_malloc(size); } void my_free_cb(void *ptr, void *user_data) { (void)user_data; my_free(ptr); } void *my_calloc_cb(size_t nmemb, size_t size, void *user_data) { (void)user_data; return my_calloc(nmemb, size); } void *my_realloc_cb(void *ptr, size_t size, void *user_data) { (void)user_data; return my_realloc(ptr, size); } void conn_new() { nghttp3_mem mem = {NULL, my_malloc_cb, my_free_cb, my_calloc_cb, my_realloc_cb}; ... }
-
void *user_data
user_datais an arbitrary user supplied data. This is passed to each allocator function.
-
nghttp3_malloc malloc
-
nghttp3_free free
-
nghttp3_calloc calloc
-
nghttp3_realloc realloc
reallocis a custom allocator function to replace realloc(3).
-
void *user_data
-
type nghttp3_vec
nghttp3_vecisstruct ioveccompatible structure to reference arbitrary array of bytes.
-
type nghttp3_rcbuf
nghttp3_rcbufis the object representing reference counted buffer. The details of this structure are intentionally hidden from the public API.
-
type nghttp3_buf
nghttp3_bufis the variable size buffer.
-
type nghttp3_nv
nghttp3_nvis the name/value pair, which mainly used to represent HTTP fields.-
uint8_t flags
flagsis bitwise OR of one or more ofNGHTTP3_NV_FLAG_*.
-
uint8_t flags
-
type nghttp3_qpack_nv
nghttp3_qpack_nvrepresents HTTP field name/value pair just likenghttp3_nv. It is an extended version ofnghttp3_nv, and has reference counted buffers and tokens.-
nghttp3_rcbuf *name
nameis the buffer containing HTTP field name. NULL-termination is guaranteed.
-
nghttp3_rcbuf *value
valueis the buffer containing HTTP field value. NULL-termination is guaranteed.
-
int32_t token
tokenisnghttp3_qpack_tokenvalue ofname. It could be -1 if we have no token for that HTTP field name.
-
uint8_t flags
flagsis a bitwise OR of one or more ofNGHTTP3_NV_FLAG_*.
-
nghttp3_rcbuf *name
-
type nghttp3_qpack_encoder
nghttp3_qpack_encoderis QPACK encoder. The details of this structure are intentionally hidden from the public API.
-
type nghttp3_qpack_stream_context
nghttp3_qpack_stream_contextis a decoder context for an individual stream. Its state is per HTTP field section. In order to reuse this object for another HTTP field section, callnghttp3_qpack_stream_context_reset(). The details of this structure are intentionally hidden from the public API.
-
type nghttp3_qpack_decoder
nghttp3_qpack_decoderis QPACK decoder. The details of this structure are intentionally hidden from the public API.
-
typedef void (*nghttp3_debug_vprintf_callback)(const char *format, va_list args)
nghttp3_debug_vprintf_callbackis a callback function invoked when the library outputs debug logging. The function is called with arguments suitable for vfprintf(3).The debug output is only enabled if the library is built with
DEBUGBUILDmacro defined.
-
type nghttp3_conn
nghttp3_connrepresents a single HTTP/3 connection. The details of this structure are intentionally hidden from the public API.
-
type nghttp3_settings
nghttp3_settingsdefines HTTP/3 settings.-
uint64_t max_field_section_size
max_field_section_sizespecifies the maximum header section (block) size.
-
size_t qpack_max_dtable_capacity
qpack_max_dtable_capacityis the maximum size of QPACK dynamic table.
-
size_t qpack_encoder_max_dtable_capacity
qpack_encoder_max_dtable_capacityis the upper bound of QPACK dynamic table capacity that the QPACK encoder is willing to use. The effective maximum dynamic table capacity is the minimum of this field and the value of the received SETTINGS_QPACK_MAX_TABLE_CAPACITY. If this field is set to 0, the encoder does not use the dynamic table.When
nghttp3_settingsis passed tonghttp3_callbacks.recv_settingscallback, this field should be ignored.
-
size_t qpack_blocked_streams
qpack_blocked_streamsis the maximum number of streams which can be blocked while they are being decoded.
-
uint8_t enable_connect_protocol
enable_connect_protocol, if set to nonzero, enables Extended CONNECT Method (see RFC 9220). Client ignores this field.
-
uint8_t h3_datagram
h3_datagram, if set to nonzero, enables HTTP/3 Datagrams (see RFC 9297).
-
const nghttp3_vec *origin_list
origin_list, if set, must contain a serialized HTTP/3 ORIGIN frame (see RFC 9412) payload. The ORIGIN frame payload is a sequence of zero or more of a length prefixed byte string. The length is encoded in 2 bytes in network byte order. Iforigin_list->lenis zero, an empty ORIGIN frame is sent. An application must keep the buffer pointed byorigin_list->basealive until thenghttp3_connto which this field was passed is freed bynghttp3_conn_del(). The object pointed to by this field is copied internally, and does not need to be kept alive. Only server uses this field. This field is available since v1.11.0.
-
uint64_t glitch_ratelim_burst
glitch_ratelim_burstis the maximum number of tokens available to “glitch” rate limiter. “glitch” is a suspicious activity from a remote endpoint. If detected, certain amount of tokens are consumed. If no tokens are available to consume, the connection is closed. The rate of token generation is specified byglitch_ratelim_rate. This feature is enabled only whennghttp3_conn_read_stream2()is used. This field has been available since v1.12.0.
-
uint64_t glitch_ratelim_rate
glitch_ratelim_rateis the number of tokens generated per second. Seeglitch_ratelim_burstfor “glitch” rate limiter. This field has been available since v1.12.0.
-
uint64_t max_field_section_size
-
typedef int (*nghttp3_acked_stream_data)(nghttp3_conn *conn, int64_t stream_id, uint64_t datalen, void *conn_user_data, void *stream_user_data)
nghttp3_acked_stream_datais a callback function which is invoked when data sent on stream denoted by stream_id supplied from application is acknowledged by remote endpoint. The number of bytes acknowledged is given in datalen.The implementation of this callback must return 0 if it succeeds. Returning
NGHTTP3_ERR_CALLBACK_FAILUREwill return to the caller immediately. Any values other than 0 is treated asNGHTTP3_ERR_CALLBACK_FAILURE.
-
typedef int (*nghttp3_stream_close)(nghttp3_conn *conn, int64_t stream_id, uint64_t app_error_code, void *conn_user_data, void *stream_user_data)
nghttp3_conn_stream_closeis a callback function which is invoked when a stream identified by stream_id is closed. QUIC application error code app_error_code indicates the reason of this closure.The implementation of this callback must return 0 if it succeeds. Returning
NGHTTP3_ERR_CALLBACK_FAILUREwill return to the caller immediately. Any values other than 0 is treated asNGHTTP3_ERR_CALLBACK_FAILURE.
-
typedef int (*nghttp3_recv_data)(nghttp3_conn *conn, int64_t stream_id, const uint8_t *data, size_t datalen, void *conn_user_data, void *stream_user_data)
nghttp3_recv_datais a callback function which is invoked when a part of request or response body on stream identified by stream_id is received. data points to the received data, and its length is datalen.The application is responsible for increasing flow control credit (say, increasing by datalen bytes).
The implementation of this callback must return 0 if it succeeds. Returning
NGHTTP3_ERR_CALLBACK_FAILUREwill return to the caller immediately. Any values other than 0 is treated asNGHTTP3_ERR_CALLBACK_FAILURE.
-
typedef int (*nghttp3_deferred_consume)(nghttp3_conn *conn, int64_t stream_id, size_t consumed, void *conn_user_data, void *stream_user_data)
nghttp3_deferred_consumeis a callback function which is invoked when the library consumed consumed bytes for a stream identified by stream_id. This callback is used to notify the consumed bytes for stream blocked due to synchronization between streams. The application is responsible for increasing flow control credit by consumed bytes.The implementation of this callback must return 0 if it succeeds. Returning
NGHTTP3_ERR_CALLBACK_FAILUREwill return to the caller immediately. Any values other than 0 is treated asNGHTTP3_ERR_CALLBACK_FAILURE.
-
typedef int (*nghttp3_begin_headers)(nghttp3_conn *conn, int64_t stream_id, void *conn_user_data, void *stream_user_data)
nghttp3_begin_headersis a callback function which is invoked when an incoming HTTP field section is started on a stream denoted by stream_id. Each HTTP field is passed to application bynghttp3_recv_headercallback. And thennghttp3_end_headersis called when a whole HTTP field section is processed.The implementation of this callback must return 0 if it succeeds. Returning
NGHTTP3_ERR_CALLBACK_FAILUREwill return to the caller immediately. Any values other than 0 is treated asNGHTTP3_ERR_CALLBACK_FAILURE.
-
typedef int (*nghttp3_recv_header)(nghttp3_conn *conn, int64_t stream_id, int32_t token, nghttp3_rcbuf *name, nghttp3_rcbuf *value, uint8_t flags, void *conn_user_data, void *stream_user_data)
nghttp3_recv_headeris a callback function which is invoked when an HTTP field is received on a stream denoted by stream_id. name contains a field name, and value contains a field value. token is one of token defined innghttp3_qpack_tokenor -1 if no token is defined for name. flags is bitwise OR of zero or more ofNGHTTP3_NV_FLAG_*.The buffers for name and value are reference counted. If application needs to keep them, increment the reference count with
nghttp3_rcbuf_incref(). When they are no longer used, callnghttp3_rcbuf_decref().The implementation of this callback must return 0 if it succeeds. Returning
NGHTTP3_ERR_CALLBACK_FAILUREwill return to the caller immediately. Any values other than 0 is treated asNGHTTP3_ERR_CALLBACK_FAILURE.
-
typedef int (*nghttp3_end_headers)(nghttp3_conn *conn, int64_t stream_id, int fin, void *conn_user_data, void *stream_user_data)
nghttp3_end_headersis a callback function which is invoked when an incoming HTTP field section has ended.If the stream ends with this HTTP field section, fin is set to nonzero.
The implementation of this callback must return 0 if it succeeds. Returning
NGHTTP3_ERR_CALLBACK_FAILUREwill return to the caller immediately. Any values other than 0 is treated asNGHTTP3_ERR_CALLBACK_FAILURE.
-
typedef int (*nghttp3_end_stream)(nghttp3_conn *conn, int64_t stream_id, void *conn_user_data, void *stream_user_data)
nghttp3_end_streamis a callback function which is invoked when the receiving side of stream is closed. For server, this callback function is invoked when HTTP request is received completely. For client, this callback function is invoked when HTTP response is received completely.The implementation of this callback must return 0 if it succeeds. Returning
NGHTTP3_ERR_CALLBACK_FAILUREwill return to the caller immediately. Any values other than 0 is treated asNGHTTP3_ERR_CALLBACK_FAILURE.
-
typedef int (*nghttp3_stop_sending)(nghttp3_conn *conn, int64_t stream_id, uint64_t app_error_code, void *conn_user_data, void *stream_user_data)
nghttp3_stop_sendingis a callback function which is invoked when the library asks application to send STOP_SENDING to the stream identified by stream_id. QUIC application error code app_error_code indicates the reason for this action.The implementation of this callback must return 0 if it succeeds. Returning
NGHTTP3_ERR_CALLBACK_FAILUREwill return to the caller immediately. Any values other than 0 is treated asNGHTTP3_ERR_CALLBACK_FAILURE.
-
typedef int (*nghttp3_reset_stream)(nghttp3_conn *conn, int64_t stream_id, uint64_t app_error_code, void *conn_user_data, void *stream_user_data)
nghttp3_reset_streamis a callback function which is invoked when the library asks application to reset stream identified by stream_id. QUIC application error code app_error_code indicates the reason for this action.The implementation of this callback must return 0 if it succeeds. Returning
NGHTTP3_ERR_CALLBACK_FAILUREwill return to the caller immediately. Any values other than 0 is treated asNGHTTP3_ERR_CALLBACK_FAILURE.
-
typedef int (*nghttp3_shutdown)(nghttp3_conn *conn, int64_t id, void *conn_user_data)
nghttp3_shutdownis a callback function which is invoked when a shutdown is initiated by the remote endpoint. For client, id contains a stream ID of a client initiated stream, for server, it contains a push ID. All client streams with stream ID, or pushes with push ID equal to, or larger than ID are guaranteed to not be processed by the remote endpoint. Note that libnghttp3 does not implement Server Push.Parameter id for client can contain a special value
NGHTTP3_SHUTDOWN_NOTICE_STREAM_ID, and for server it can contain special valueNGHTTP3_SHUTDOWN_NOTICE_PUSH_ID. These values signal request for graceful shutdown of the connection, triggered by remote endpoint’s invocation ofnghttp3_conn_submit_shutdown_notice().It is possible that this callback is invoked multiple times on a single connection, however the id can only stay the same or decrease, never increase.
The implementation of this callback must return 0 if it succeeds. Returning
NGHTTP3_ERR_CALLBACK_FAILUREwill return to the caller immediately. Any values other than 0 is treated asNGHTTP3_ERR_CALLBACK_FAILURE.
-
typedef int (*nghttp3_recv_settings)(nghttp3_conn *conn, const nghttp3_settings *settings, void *conn_user_data)
nghttp3_recv_settingsis a callback function which is invoked when SETTINGS frame is received. settings is a received remote HTTP/3 settings.The implementation of this callback must return 0 if it succeeds. Returning
NGHTTP3_ERR_CALLBACK_FAILUREwill return to the caller immediately. Any values other than 0 is treated asNGHTTP3_ERR_CALLBACK_FAILURE.
-
typedef int (*nghttp3_recv_origin)(nghttp3_conn *conn, const uint8_t *origin, size_t originlen, void *conn_user_data)
nghttp3_recv_originis a callback function which is invoked when a single origin in ORIGIN frame is received. origin is a received origin of length originlen. originlen never be 0.The implementation of this callback must return 0 if it succeeds. Returning
NGHTTP3_ERR_CALLBACK_FAILUREwill return to the caller immediately. Any values other than 0 is treated asNGHTTP3_ERR_CALLBACK_FAILURE.
-
typedef int (*nghttp3_end_origin)(nghttp3_conn *conn, void *conn_user_data)
nghttp3_end_originis a callback function which is invoked when an ORIGIN frame has been completely processed.The implementation of this callback must return 0 if it succeeds. Returning
NGHTTP3_ERR_CALLBACK_FAILUREwill return to the caller immediately. Any values other than 0 is treated asNGHTTP3_ERR_CALLBACK_FAILURE.
-
typedef void (*nghttp3_rand)(uint8_t *dest, size_t destlen)
nghttp3_randis a callback function which is invoked when unpredictable data of destlen bytes are needed. The implementation must write unpredictable data of destlen bytes into the buffer pointed by dest.
-
type nghttp3_callbacks
nghttp3_callbacksholds a set of callback functions.-
nghttp3_acked_stream_data acked_stream_data
acked_stream_datais a callback function which is invoked when data sent on a particular stream have been acknowledged by a remote endpoint.
-
nghttp3_stream_close stream_close
stream_closeis a callback function which is invoked when a particular stream has closed.
-
nghttp3_recv_data recv_data
recv_datais a callback function which is invoked when stream data is received.
-
nghttp3_deferred_consume deferred_consume
deferred_consumeis a callback function which is invoked when the library consumed data for a particular stream which had been blocked for synchronization between streams.
-
nghttp3_begin_headers begin_headers
begin_headersis a callback function which is invoked when an HTTP header field section has started on a particular stream.
-
nghttp3_recv_header recv_header
recv_headeris a callback function which is invoked when a single HTTP header field is received on a particular stream.
-
nghttp3_end_headers end_headers
end_headersis a callback function which is invoked when an HTTP header field section has ended on a particular stream.
-
nghttp3_begin_headers begin_trailers
begin_trailersis a callback function which is invoked when an HTTP trailer field section has started on a particular stream.
-
nghttp3_recv_header recv_trailer
recv_traileris a callback function which is invoked when a single HTTP trailer field is received on a particular stream.
-
nghttp3_end_headers end_trailers
end_trailersis a callback function which is invoked when an HTTP trailer field section has ended on a particular stream.
-
nghttp3_stop_sending stop_sending
stop_sendingis a callback function which is invoked when the library asks application to send STOP_SENDING to a particular stream.
-
nghttp3_end_stream end_stream
end_streamis a callback function which is invoked when a receiving side of stream has been closed.
-
nghttp3_reset_stream reset_stream
reset_streamis a callback function which is invoked when the library asks application to reset stream (by sending RESET_STREAM).
-
nghttp3_shutdown shutdown
shutdownis a callback function which is invoked when the remote endpoint has signalled initiation of connection shutdown.
-
nghttp3_recv_settings recv_settings
recv_settingsis a callback function which is invoked when SETTINGS frame is received.
-
nghttp3_recv_origin recv_origin
recv_originis a callback function which is invoked when a single origin in an ORIGIN frame is received. This field is available since v1.11.0.
-
nghttp3_end_origin end_origin
end_originis a callback function which is invoked when an ORIGIN frame has been completely processed. This field is available since v1.11.0.
-
nghttp3_rand rand
randis a callback function which is invoked when unpredictable data are needed. Although this field is optional due to the backward compatibility, it is recommended to specify this field to harden the runtime behavior against suspicious activities of a remote endpoint. This field is available since v1.11.0.
-
nghttp3_acked_stream_data acked_stream_data
-
typedef nghttp3_ssize (*nghttp3_read_data_callback)(nghttp3_conn *conn, int64_t stream_id, nghttp3_vec *vec, size_t veccnt, uint32_t *pflags, void *conn_user_data, void *stream_user_data)
nghttp3_read_data_callbackis a callback function invoked when the library asks an application to provide stream data for a stream denoted by stream_id.The library provides vec of length veccnt to the application. The application should fill data and its length to vec. It has to return the number of the filled objects. The application must retain data until they are safe to free. It is notified by
nghttp3_acked_stream_datacallback.If this is the last data to send (or there is no data to send because all data have been sent already), set
NGHTTP3_DATA_FLAG_EOFto *pflags.If the application is unable to provide data temporarily, return
NGHTTP3_ERR_WOULDBLOCK. When it is ready to provide data, callnghttp3_conn_resume_stream().The callback should return the number of objects in vec that the application filled if it succeeds, or
NGHTTP3_ERR_CALLBACK_FAILURE.TODO Add NGHTTP3_ERR_TEMPORAL_CALLBACK_FAILURE to reset just this stream.
-
type nghttp3_data_reader
nghttp3_data_readerspecifies the way how to generate request or response body.-
nghttp3_read_data_callback read_data
read_datais a callback function to generate body.
-
nghttp3_read_data_callback read_data
-
type nghttp3_pri
nghttp3_prirepresents HTTP priority.-
uint32_t urgency
urgencyis the urgency of a stream, it must be in [NGHTTP3_URGENCY_HIGH,NGHTTP3_URGENCY_LOW], inclusive, and 0 is the highest urgency.
-
uint32_t urgency
-
type nghttp3_info
nghttp3_infois whatnghttp3_version()returns. It holds information about the particular nghttp3 version.-
int age
ageis the age of this struct. This instance of nghttp3 sets it toNGHTTP3_VERSION_AGEbut a future version may bump it and add more struct fields at the bottom
-
int version_num
version_numis theNGHTTP3_VERSION_NUMnumber (since age == 1)
-
const char *version_str
version_strpoints to theNGHTTP3_VERSIONstring (since age ==1)
-
int age