Inflater.inflate

Inflates name/value block stored in |input| with length |input.length|. This function performs decompression. For each successful emission of header field, InflateFlag.EMIT is set in |inflate_flags| and a header field is assigned to |hf_out| and the function returns. The caller must not free the members of |hf_out|.

The |hf_out| may include pointers to the memory region in the |input|. The caller must retain the |input| while the |hf_out| is used.

The application should call this function repeatedly until the (*inflate_flags) & InflateFlag.FINAL is true and return value is non-negative. This means the all input values are processed successfully. Then the application must call endHeaders() to prepare for the next header block input.

The caller can feed complete compressed header block. It also can feed it in several chunks. The caller must set |is_final| to true if the given input is the last block of the compressed header.

This function returns the number of bytes processed if it succeeds, or one of the following negative error codes:

ErrorCode.HEADER_COMP Inflation process has failed. ErrorCode.BUFFER_ERROR The heder field name or value is too large.

Example follows::

void inflateHeaderBlock(ref Inflater hd_inflater, ubyte[] input, bool final) { size_t rv;

for(;;) { HeaderField nv; InflateFlag inflate_flags;

rv = hd_inflater.inflate(hf, inflate_flags, input, final);

if(rv < 0) { fprintf(stderr, "inflate failed with error code %d", rv); return; }

input = input[rv .. $];

if(inflate_flags & InflateFlag.EMIT) { writeln(hf.name, " => ", hf.value); }

if(inflate_flags & InflateFlag.FINAL) { hd_inflater.endHeaders(); break; } if((inflate_flags & InflateFlag.EMIT) == 0 && input.length == 0) { break; } } }

struct Inflater
int
inflate
()

Meta