+PHP_HTTP_API STATUS _http_encoding_deflate_stream_flush(http_encoding_stream *s, char **encoded, size_t *encoded_len TSRMLS_DC)
+{
+ int status;
+
+ s->stream.avail_in = 0;
+ s->stream.next_in = NULL;
+ s->stream.avail_out = *encoded_len = 0x800;
+ s->stream.next_out = *encoded = emalloc(*encoded_len);
+
+ switch (status = deflate(&s->stream, Z_SYNC_FLUSH))
+ {
+ case Z_OK:
+ case Z_STREAM_END:
+ *encoded_len = 0x800 - s->stream.avail_out;
+ *encoded = erealloc(*encoded, *encoded_len + 1);
+ (*encoded)[*encoded_len] = '\0';
+ return SUCCESS;
+ break;
+ }
+
+ STR_SET(*encoded, NULL);
+ *encoded_len = 0;
+ http_error_ex(HE_WARNING, HTTP_E_ENCODING, "Failed to flush deflate stream: %s", zError(status));
+ return FAILURE;
+}
+
+PHP_HTTP_API STATUS _http_encoding_inflate_stream_flush(http_encoding_stream *s, char **decoded, size_t *decoded_len TSRMLS_DC)
+{
+ int status;
+
+ s->stream.avail_in = 0;
+ s->stream.next_in = NULL;
+ s->stream.avail_out = *decoded_len = 0x800;
+ s->stream.next_out = *decoded = emalloc(*decoded_len);
+
+ switch (status = inflate(&s->stream, Z_SYNC_FLUSH))
+ {
+ case Z_OK:
+ case Z_STREAM_END:
+ *decoded_len = 0x800 - s->stream.avail_out;
+ *decoded = erealloc(*decoded, *decoded_len + 1);
+ (*decoded)[*decoded_len] = '\0';
+ return SUCCESS;
+ break;
+ }
+
+ STR_SET(*decoded, NULL);
+ *decoded_len = 0;
+ http_error_ex(HE_WARNING, HTTP_E_ENCODING, "Failed to flush inflate stream: %s", zError(status));
+ return FAILURE;
+}
+
+PHP_HTTP_API STATUS _http_encoding_deflate_stream_finish(http_encoding_stream *s, char **encoded, size_t *encoded_len TSRMLS_DC)