MCPcopy Create free account
hub / github.com/apache/trafficserver / gzip_transform_finish

Function gzip_transform_finish

plugins/compress/compress.cc:508–548  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

506}
507
508static void
509gzip_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
551static void

Callers 1

Calls 5

TSIOBufferStartFunction · 0.85
TSIOBufferProduceFunction · 0.85
errorFunction · 0.85
log_compression_ratioFunction · 0.85

Tested by

no test coverage detected