| 506 | } |
| 507 | |
| 508 | static void |
| 509 | gzip_transform_finish(Data *data) |
| 510 | { |
| 511 | if (data->state == transform_state_output) { |
| 512 | TSIOBufferBlock downstream_blkp; |
| 513 | int64_t downstream_length; |
| 514 | |
| 515 | data->state = transform_state_finished; |
| 516 | |
| 517 | for (;;) { |
| 518 | downstream_blkp = TSIOBufferStart(data->downstream_buffer); |
| 519 | |
| 520 | char *downstream_buffer = TSIOBufferBlockWriteStart(downstream_blkp, &downstream_length); |
| 521 | data->zstrm.next_out = reinterpret_cast<unsigned char *>(downstream_buffer); |
| 522 | data->zstrm.avail_out = downstream_length; |
| 523 | |
| 524 | int err = deflate(&data->zstrm, Z_FINISH); |
| 525 | |
| 526 | if (downstream_length > static_cast<int64_t>(data->zstrm.avail_out)) { |
| 527 | TSIOBufferProduce(data->downstream_buffer, downstream_length - data->zstrm.avail_out); |
| 528 | data->downstream_length += (downstream_length - data->zstrm.avail_out); |
| 529 | } |
| 530 | |
| 531 | if (err == Z_OK) { /* some more data to encode */ |
| 532 | continue; |
| 533 | } |
| 534 | |
| 535 | if (err != Z_STREAM_END) { |
| 536 | warning("deflate should report Z_STREAM_END"); |
| 537 | } |
| 538 | break; |
| 539 | } |
| 540 | |
| 541 | if (data->downstream_length != static_cast<int64_t>(data->zstrm.total_out)) { |
| 542 | error("gzip-transform: output lengths don't match (%d, %ld)", data->downstream_length, data->zstrm.total_out); |
| 543 | } |
| 544 | |
| 545 | debug("gzip-transform: Finished gzip"); |
| 546 | log_compression_ratio(data->zstrm.total_in, data->downstream_length); |
| 547 | } |
| 548 | } |
| 549 | |
| 550 | #if HAVE_BROTLI_ENCODE_H |
| 551 | static void |
no test coverage detected