| 467 | #endif |
| 468 | |
| 469 | static void |
| 470 | compress_transform_one(Data *data, TSIOBufferReader upstream_reader, int amount) |
| 471 | { |
| 472 | TSIOBufferBlock downstream_blkp; |
| 473 | int64_t upstream_length; |
| 474 | while (amount > 0) { |
| 475 | downstream_blkp = TSIOBufferReaderStart(upstream_reader); |
| 476 | if (!downstream_blkp) { |
| 477 | error("couldn't get from IOBufferBlock"); |
| 478 | return; |
| 479 | } |
| 480 | |
| 481 | const char *upstream_buffer = TSIOBufferBlockReadStart(downstream_blkp, upstream_reader, &upstream_length); |
| 482 | if (!upstream_buffer) { |
| 483 | error("couldn't get from TSIOBufferBlockReadStart"); |
| 484 | return; |
| 485 | } |
| 486 | |
| 487 | if (upstream_length > amount) { |
| 488 | upstream_length = amount; |
| 489 | } |
| 490 | |
| 491 | #if HAVE_BROTLI_ENCODE_H |
| 492 | if (data->compression_type & COMPRESSION_TYPE_BROTLI && (data->compression_algorithms & ALGORITHM_BROTLI)) { |
| 493 | brotli_transform_one(data, upstream_buffer, upstream_length); |
| 494 | } else |
| 495 | #endif |
| 496 | if ((data->compression_type & (COMPRESSION_TYPE_GZIP | COMPRESSION_TYPE_DEFLATE)) && |
| 497 | (data->compression_algorithms & (ALGORITHM_GZIP | ALGORITHM_DEFLATE))) { |
| 498 | gzip_transform_one(data, upstream_buffer, upstream_length); |
| 499 | } else { |
| 500 | warning("No compression supported. Shouldn't come here."); |
| 501 | } |
| 502 | |
| 503 | TSIOBufferReaderConsume(upstream_reader, upstream_length); |
| 504 | amount -= upstream_length; |
| 505 | } |
| 506 | } |
| 507 | |
| 508 | static void |
| 509 | gzip_transform_finish(Data *data) |
no test coverage detected