| 3757 | */ |
| 3758 | |
| 3759 | static void |
| 3760 | http_content_coding_finish( |
| 3761 | http_t *http) /* I - HTTP connection */ |
| 3762 | { |
| 3763 | int zerr; /* Compression status */ |
| 3764 | Byte dummy[1]; /* Dummy read buffer */ |
| 3765 | size_t bytes; /* Number of bytes to write */ |
| 3766 | |
| 3767 | |
| 3768 | DEBUG_printf(("http_content_coding_finish(http=%p)", (void *)http)); |
| 3769 | DEBUG_printf(("1http_content_coding_finishing: http->coding=%d", http->coding)); |
| 3770 | |
| 3771 | switch (http->coding) |
| 3772 | { |
| 3773 | case _HTTP_CODING_DEFLATE : |
| 3774 | case _HTTP_CODING_GZIP : |
| 3775 | ((z_stream *)http->stream)->next_in = dummy; |
| 3776 | ((z_stream *)http->stream)->avail_in = 0; |
| 3777 | |
| 3778 | do |
| 3779 | { |
| 3780 | zerr = deflate((z_stream *)http->stream, Z_FINISH); |
| 3781 | bytes = _HTTP_MAX_SBUFFER - ((z_stream *)http->stream)->avail_out; |
| 3782 | |
| 3783 | if (bytes > 0) |
| 3784 | { |
| 3785 | DEBUG_printf(("1http_content_coding_finish: Writing trailing chunk, len=%d", (int)bytes)); |
| 3786 | |
| 3787 | if (http->data_encoding == HTTP_ENCODING_CHUNKED) |
| 3788 | http_write_chunk(http, (char *)http->sbuffer, bytes); |
| 3789 | else |
| 3790 | http_write(http, (char *)http->sbuffer, bytes); |
| 3791 | } |
| 3792 | |
| 3793 | ((z_stream *)http->stream)->next_out = (Bytef *)http->sbuffer; |
| 3794 | ((z_stream *)http->stream)->avail_out = (uInt)_HTTP_MAX_SBUFFER; |
| 3795 | } |
| 3796 | while (zerr == Z_OK); |
| 3797 | |
| 3798 | deflateEnd((z_stream *)http->stream); |
| 3799 | |
| 3800 | free(http->sbuffer); |
| 3801 | free(http->stream); |
| 3802 | |
| 3803 | http->sbuffer = NULL; |
| 3804 | http->stream = NULL; |
| 3805 | |
| 3806 | if (http->wused) |
| 3807 | httpFlushWrite(http); |
| 3808 | break; |
| 3809 | |
| 3810 | case _HTTP_CODING_INFLATE : |
| 3811 | case _HTTP_CODING_GUNZIP : |
| 3812 | inflateEnd((z_stream *)http->stream); |
| 3813 | |
| 3814 | free(http->sbuffer); |
| 3815 | free(http->stream); |
| 3816 |
no test coverage detected