Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix debian build - libzstd #1262

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading