11 using namespace folly;
15 ZlibCertificateCompressor::ZlibCertificateCompressor(
int compressLevel)
16 : level_(compressLevel) {
17 if (compressLevel != Z_DEFAULT_COMPRESSION &&
18 !(compressLevel >= Z_NO_COMPRESSION &&
19 compressLevel <= Z_BEST_COMPRESSION)) {
20 throw std::runtime_error(
21 "Invalid compression level requested:" +
22 to<std::string>(compressLevel));
33 auto encoded =
encode(cert);
34 auto certRange = encoded->coalesce();
35 auto compressedCert = IOBuf::create(compressBound(certRange.size()));
36 unsigned long size = compressedCert->capacity();
38 int status = ::compress2(
39 compressedCert->writableData(),
46 compressedCert->append(size);
49 throw std::runtime_error(
"Insufficient memory to compress cert");
51 throw std::runtime_error(
"Buffer too small for compressed cert");
53 throw std::runtime_error(
54 "Compression level invalid: " + to<std::string>(
level_));
56 throw std::runtime_error(
57 "Failed to compress: " + to<std::string>(status));
CertificateCompressionAlgorithm algorithm
CertificateCompressionAlgorithm
constexpr detail::Map< Move > move
uint32_t uncompressed_length
The non test part of the code is expected to have failures gtest_output_test_ cc
—— Concurrent Priority Queue Implementation ——
CertificateCompressionAlgorithm getAlgorithm() const override
constexpr auto size(C const &c) -> decltype(c.size())
CompressedCertificate compress(const CertificateMsg &) override
Buf encode(TokenBindingMessage &&message)
Buf compressed_certificate_message