2 * nghttp2 - HTTP/2 C Library
4 * Copyright (c) 2012 Tatsuhiro Tsujikawa
6 * Permission is hereby granted, free of charge, to any person obtaining
7 * a copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sublicense, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
14 * The above copyright notice and this permission notice shall be
15 * included in all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 #ifndef NGHTTP2_GZIP_H
29 #endif /* HAVE_CONFIG_H */
32 #include <nghttp2/nghttp2.h>
41 * The gzip stream to inflate data.
51 * A helper function to set up a per request gzip stream to inflate
54 * This function returns 0 if it succeeds, or -1.
56 int nghttp2_gzip_inflate_new(nghttp2_gzip **inflater_ptr);
61 * Frees the inflate stream. The |inflater| may be ``NULL``.
63 void nghttp2_gzip_inflate_del(nghttp2_gzip *inflater);
68 * Inflates data in |in| with the length |*inlen_ptr| and stores the
69 * inflated data to |out| which has allocated size at least
70 * |*outlen_ptr|. On return, |*outlen_ptr| is updated to represent
71 * the number of data written in |out|. Similarly, |*inlen_ptr| is
72 * updated to represent the number of input bytes processed.
74 * This function returns 0 if it succeeds, or -1.
76 * The example follows::
78 * void on_data_chunk_recv_callback(nghttp2_session *session,
81 * const uint8_t *data, size_t len,
85 * req = nghttp2_session_get_stream_user_data(session, stream_id);
86 * nghttp2_gzip *inflater = req->inflater;
88 * uint8_t out[MAX_OUTLEN];
89 * size_t outlen = MAX_OUTLEN;
92 * rv = nghttp2_gzip_inflate(inflater, out, &outlen, data, &tlen);
94 * nghttp2_submit_rst_stream(session, stream_id,
95 * NGHTTP2_INTERNAL_ERROR);
105 int nghttp2_gzip_inflate(nghttp2_gzip *inflater, uint8_t *out,
106 size_t *outlen_ptr, const uint8_t *in,
112 * Returns nonzero if |inflater| sees the end of deflate stream.
113 * After this function returns nonzero, `nghttp2_gzip_inflate()` with
114 * |inflater| gets to return error.
116 int nghttp2_gzip_inflate_finished(nghttp2_gzip *inflater);
122 #endif /* NGHTTP2_GZIP_H */