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,
16 :macro:`nghttp2_hd_inflate_flag.NGHTTP2_HD_INFLATE_EMIT` is set in
17 *\*inflate_flags* and name/value pair is assigned to the *nv_out*
18 and the function returns. The caller must not free the members of
21 The *nv_out* may include pointers to the memory region in the *in*.
22 The caller must retain the *in* while the *nv_out* is used.
24 The application should call this function repeatedly until the
25 ``(*inflate_flags) & NGHTTP2_HD_INFLATE_FINAL`` is nonzero and
26 return value is non-negative. If that happens, all given input
27 data (*inlen* bytes) are processed successfully. Then the
28 application must call `nghttp2_hd_inflate_end_headers()` to prepare
29 for the next header block input.
31 In other words, if *in_final* is nonzero, and this function returns
32 *inlen*, you can assert that
33 :macro:`nghttp2_hd_inflate_final.NGHTTP2_HD_INFLATE_FINAL` is set in
36 The caller can feed complete compressed header block. It also can
37 feed it in several chunks. The caller must set *in_final* to
38 nonzero if the given input is the last block of the compressed
41 This function returns the number of bytes processed if it succeeds,
42 or one of the following negative error codes:
44 :macro:`nghttp2_error.NGHTTP2_ERR_NOMEM`
46 :macro:`nghttp2_error.NGHTTP2_ERR_HEADER_COMP`
47 Inflation process has failed.
48 :macro:`nghttp2_error.NGHTTP2_ERR_BUFFER_ERROR`
49 The header field name or value is too large.
53 int inflate_header_block(nghttp2_hd_inflater *hd_inflater,
54 uint8_t *in, size_t inlen, int final)
60 int inflate_flags = 0;
62 rv = nghttp2_hd_inflate_hd2(hd_inflater, &nv, &inflate_flags,
66 fprintf(stderr, "inflate failed with error code %zd", rv);
73 if(inflate_flags & NGHTTP2_HD_INFLATE_EMIT) {
74 fwrite(nv.name, nv.namelen, 1, stderr);
75 fprintf(stderr, ": ");
76 fwrite(nv.value, nv.valuelen, 1, stderr);
77 fprintf(stderr, "\n");
79 if(inflate_flags & NGHTTP2_HD_INFLATE_FINAL) {
80 nghttp2_hd_inflate_end_headers(hd_inflater);
83 if((inflate_flags & NGHTTP2_HD_INFLATE_EMIT) == 0 &&