nghttp2_hpack_decoder_read
Synopsis
#include <nghttp2v2/nghttp2.h>
-
nghttp2_ssize nghttp2_hpack_decoder_read(nghttp2_hpack_decoder *dec, nghttp2_hpack_nv *dest, uint8_t *pflags, const uint8_t *src, size_t srclen, int fin)
nghttp2_hpack_decoder_read()reads the encoded HPACK stream given by the buffer pointed by src of length srclen bytes. *pflags must be non-NULL pointer. dest must be non-NULL pointer.If this function succeeds, it assigns flags to *pflags. If *pflags has
NGHTTP2_HPACK_DECODE_FLAG_EMITset, a decoded HTTP field is assigned to dest. If *pflags hasNGHTTP2_HPACK_DECODE_FLAG_FINALset, the entire HTTP field section has been successfully decoded.When an HTTP field is decoded, the caller receives it in dest.
dest->nameanddest->valueare reference counted buffer, and their reference counts are already incremented for application use. Therefore, when the caller finishes processing dest, it must callnghttp2_rcbuf_decref(dest->name)andnghttp2_rcbuf_decref(dest->value), or memory leak might occur. Thesenghttp2_rcbufobjects hold the pointer tonghttp2_memthat is passed tonghttp2_hpack_decoder_new(). As long as these objects are alive, the pointednghttp2_memobject must be available. Otherwise,nghttp2_rcbuf_decref()causes undefined behavior.This function returns the number of bytes read, or one of the following negative error codes:
NGHTTP2_ERR_NOMEMOut of memory.
NGHTTP2_ERR_HPACK_FATALdec is in unrecoverable error state, and cannot be used anymore.