| 365 | } |
| 366 | |
| 367 | static void |
| 368 | gzip_transform_one(Data *data, const char *upstream_buffer, int64_t upstream_length) |
| 369 | { |
| 370 | TSIOBufferBlock downstream_blkp; |
| 371 | int64_t downstream_length; |
| 372 | int err; |
| 373 | data->zstrm.next_in = (unsigned char *)upstream_buffer; |
| 374 | data->zstrm.avail_in = upstream_length; |
| 375 | |
| 376 | while (data->zstrm.avail_in > 0) { |
| 377 | downstream_blkp = TSIOBufferStart(data->downstream_buffer); |
| 378 | char *downstream_buffer = TSIOBufferBlockWriteStart(downstream_blkp, &downstream_length); |
| 379 | |
| 380 | data->zstrm.next_out = reinterpret_cast<unsigned char *>(downstream_buffer); |
| 381 | data->zstrm.avail_out = downstream_length; |
| 382 | |
| 383 | if (!data->hc->flush()) { |
| 384 | err = deflate(&data->zstrm, Z_NO_FLUSH); |
| 385 | } else { |
| 386 | err = deflate(&data->zstrm, Z_SYNC_FLUSH); |
| 387 | } |
| 388 | |
| 389 | if (err != Z_OK) { |
| 390 | warning("deflate() call failed: %d", err); |
| 391 | } |
| 392 | |
| 393 | if (downstream_length > data->zstrm.avail_out) { |
| 394 | TSIOBufferProduce(data->downstream_buffer, downstream_length - data->zstrm.avail_out); |
| 395 | data->downstream_length += (downstream_length - data->zstrm.avail_out); |
| 396 | } |
| 397 | |
| 398 | if (data->zstrm.avail_out > 0) { |
| 399 | if (data->zstrm.avail_in != 0) { |
| 400 | error("gzip-transform: avail_in is (%d): should be 0", data->zstrm.avail_in); |
| 401 | } |
| 402 | } |
| 403 | } |
| 404 | } |
| 405 | |
| 406 | #if HAVE_BROTLI_ENCODE_H |
| 407 | static bool |
no test coverage detected