Skip to content

Commit

Permalink
Update: Removed use of defaultCLevel function
Browse files Browse the repository at this point in the history
  • Loading branch information
EdgarModesto23 committed Nov 12, 2024
1 parent 2e98845 commit d285317
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
9 changes: 7 additions & 2 deletions include/pistache/http.h
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,8 @@ namespace Pistache
return nullptr;
}



// Compress using the requested content encoding, if supported,
// before sending bits to client. Content-Encoding header will be
// automatically set to the requested encoding, if supported...
Expand All @@ -535,7 +537,8 @@ namespace Pistache
}
#endif
#ifdef PISTACHE_USE_CONTENT_ENCODING_ZSTD

// Set the compression level for zstandard algorithm. Defaults to
// ZSTD_CLEVEL_DEFAULT = 3...
void setCompressionZstdLevel(const int contentEncodingZstdLevel)
{
contentEncodingZstdLevel_ = contentEncodingZstdLevel;
Expand Down Expand Up @@ -575,7 +578,9 @@ namespace Pistache
#endif

#ifdef PISTACHE_USE_CONTENT_ENCODING_ZSTD
int contentEncodingZstdLevel_ = ZSTD_defaultCLevel();

// Value 0 means default, which is controlled by ZSTD_CLEVEL_DEFAULT = 3
int contentEncodingZstdLevel_ = 0;
#endif

#ifdef PISTACHE_USE_CONTENT_ENCODING_DEFLATE
Expand Down
4 changes: 1 addition & 3 deletions src/common/http.cc
Original file line number Diff line number Diff line change
Expand Up @@ -933,14 +933,12 @@ namespace Pistache::Http
#ifdef PISTACHE_USE_CONTENT_ENCODING_ZSTD

case Http::Header::Encoding::Zstd: {
// Get max compressed size
size_t estimated_size = ZSTD_compressBound(size);
// Allocate a smart buffer to contain compressed data...
std::unique_ptr compressedData = std::make_unique<std::byte[]>(estimated_size);

// Compress data using default compression level: https://raw.githack.com/facebook/zstd/release/doc/zstd_manual.html#Chapter3
auto compress_size = ZSTD_compress(reinterpret_cast<void*>(compressedData.get()), estimated_size,
data, size, ZSTD_defaultCLevel());
data, size, contentEncodingZstdLevel_);
if (ZSTD_isError(compress_size))
{
throw std::runtime_error(
Expand Down
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.4.17.20241110
0.4.17.20241111

0 comments on commit d285317

Please sign in to comment.