nghttp3_qpack_encoder_encode
Synopsis
#include <nghttp3/nghttp3.h>
-
int nghttp3_qpack_encoder_encode(nghttp3_qpack_encoder *encoder, nghttp3_buf *pbuf, nghttp3_buf *rbuf, nghttp3_buf *ebuf, int64_t stream_id, const nghttp3_nv *nva, size_t nvlen)
nghttp3_qpack_encoder_encode()
encodes the list of HTTP fields nva. nvlen is the length of nva. stream_id is the identifier of the stream which these HTTP fields belong to. This function writes field section prefix, encoded HTTP field section, and encoder stream to pbuf, rbuf, and ebuf respectively. Eachnghttp3_buf.last
will be adjusted when data is written. An application should write pbuf and rbuf to the request stream in this order.The buffer pointed by pbuf, rbuf, and ebuf can be empty buffer. It is fine to pass a buffer initialized by
nghttp3_buf_init(buf)
. This function allocates memory for these buffers as necessary. In particular, it frees and expands buffer if the current capacity of buffer is not enough. Ifnghttp3_buf.begin
of any buffer is not NULL, it must be allocated by the same memory allocator passed tonghttp3_qpack_encoder_new()
.This function returns 0 if it succeeds, or one of the following negative error codes:
NGHTTP3_ERR_NOMEM
Out of memory
NGHTTP3_ERR_QPACK_FATAL
encoder is in unrecoverable error state, and cannot be used anymore.