8 *#include <nghttp2/nghttp2.h>*
10 .. function:: ssize_t nghttp2_hd_inflate_hd2(nghttp2_hd_inflater *inflater, nghttp2_nv *nv_out, int *inflate_flags, const uint8_t *in, size_t inlen, int in_final)
13 Inflates name/value block stored in *in* with length *inlen*. This
14 function performs decompression. For each successful emission of
15 header name/value pair, :macro:`NGHTTP2_HD_INFLATE_EMIT` is set in
16 *\*inflate_flags* and name/value pair is assigned to the *nv_out*
17 and the function returns. The caller must not free the members of
20 The *nv_out* may include pointers to the memory region in the *in*.
21 The caller must retain the *in* while the *nv_out* is used.
23 The application should call this function repeatedly until the
24 ``(*inflate_flags) & NGHTTP2_HD_INFLATE_FINAL`` is nonzero and
25 return value is non-negative. If that happens, all given input
26 data (*inlen* bytes) are processed successfully. Then the
27 application must call `nghttp2_hd_inflate_end_headers()` to prepare
28 for the next header block input.
30 In other words, if *in_final* is nonzero, and this function returns
31 *inlen*, you can assert that :macro:`NGHTTP2_HD_INFLATE_FINAL` is
32 set in *\*inflate_flags*.
34 The caller can feed complete compressed header block. It also can
35 feed it in several chunks. The caller must set *in_final* to
36 nonzero if the given input is the last block of the compressed
39 This function returns the number of bytes processed if it succeeds,
40 or one of the following negative error codes:
42 :macro:`NGHTTP2_ERR_NOMEM`
44 :macro:`NGHTTP2_ERR_HEADER_COMP`
45 Inflation process has failed.
46 :macro:`NGHTTP2_ERR_BUFFER_ERROR`
47 The header field name or value is too large.
51 int inflate_header_block(nghttp2_hd_inflater *hd_inflater,
52 uint8_t *in, size_t inlen, int final)
58 int inflate_flags = 0;
60 rv = nghttp2_hd_inflate_hd2(hd_inflater, &nv, &inflate_flags,
64 fprintf(stderr, "inflate failed with error code %zd", rv);
71 if(inflate_flags & NGHTTP2_HD_INFLATE_EMIT) {
72 fwrite(nv.name, nv.namelen, 1, stderr);
73 fprintf(stderr, ": ");
74 fwrite(nv.value, nv.valuelen, 1, stderr);
75 fprintf(stderr, "\n");
77 if(inflate_flags & NGHTTP2_HD_INFLATE_FINAL) {
78 nghttp2_hd_inflate_end_headers(hd_inflater);
81 if((inflate_flags & NGHTTP2_HD_INFLATE_EMIT) == 0 &&