adamdebreceni commented on code in PR #1344:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1344#discussion_r891144229
##########
extensions/http-curl/protocols/RESTSender.cpp:
##########
@@ -124,10 +133,30 @@ C2Payload RESTSender::sendPayload(const std::string url,
const Direction directi
} else {
auto data_input = std::make_unique<utils::ByteInputCallback>();
auto data_cb = std::make_unique<utils::HTTPUploadCallback>();
- data_input->write(data.value_or(""));
+ if (data && req_encoding_ == RequestEncoding::Gzip) {
+ io::BufferStream compressed_payload;
+ bool compression_success = [&] {
+ io::ZlibCompressStream
compressor(gsl::make_not_null(&compressed_payload),
io::ZlibCompressionFormat::GZIP, Z_BEST_COMPRESSION);
+ auto ret = compressor.write(gsl::span<const
char>(data.value()).as_span<const std::byte>());
+ if (ret != data->length()) {
+ return false;
Review Comment:
`compressor.close()` makes sure that the archive is complete and no more
data is to be compressed, but the destructor will tear down the `z_stream`
object regardless
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]