Skip to content

Support HTTP response compression#50

Merged
dkropachev merged 1 commit into
mainfrom
dk/driver-626-response-compression
Jul 13, 2026
Merged

Support HTTP response compression#50
dkropachev merged 1 commit into
mainfrom
dk/driver-626-response-compression

Conversation

@dkropachev

@dkropachev dkropachev commented Jul 13, 2026

Copy link
Copy Markdown
Collaborator

Jira task: https://scylladb.atlassian.net/browse/DRIVER-626

Fixes #29

Summary

  • add optional HTTP response compression; default Config advertises no Accept-Encoding and does not decode compressed responses
  • replace the separate accepted-encoding knob and single decoder with decoder-owned encodings via Config::content_encoding_decoders
  • add generic HttpContentEncodingDecoder API so each decoder advertises its accepted response encodings and decodes the specific matching content-encoding token
  • validate decoder configuration: no null decoders, no empty advertised encodings, and each normalized encoding is owned by exactly one decoder
  • add optional concrete ZlibContentEncodingDecoder for gzip/deflate when zlib is available; callers must configure it explicitly and can advertise a gzip/deflate subset
  • decode discovery and DynamoDB AWS SDK HTTP-factory responses only when the response encoding is configured
  • keep DynamoDB compression scoped to the HTTP factory path and only set Accept-Encoding for requests routed to Alternator nodes
  • document optional zlib support, custom decoder usage, gzip+zstd composition, and the factory requirement for DynamoDB operations

API Surface

class HttpContentEncodingDecoder {
public:
    virtual ~HttpContentEncodingDecoder() = default;

    [[nodiscard]] virtual std::vector<std::string> AcceptedResponseEncodings() const = 0;
    [[nodiscard]] virtual std::string Decode(std::string body, const std::string& content_encoding) const = 0;
};

class ZlibContentEncodingDecoder final : public HttpContentEncodingDecoder {
public:
    explicit ZlibContentEncodingDecoder(std::vector<std::string> accepted_response_encodings = {"gzip", "deflate"});

    [[nodiscard]] std::vector<std::string> AcceptedResponseEncodings() const override;
    [[nodiscard]] std::string Decode(std::string body, const std::string& content_encoding) const override;
};

struct Config {
    std::vector<std::shared_ptr<HttpContentEncodingDecoder>> content_encoding_decoders;
};

Examples:

scylladb::alternator::Config cfg;
cfg.content_encoding_decoders.push_back(
    std::make_shared<scylladb::alternator::ZlibContentEncodingDecoder>());
scylladb::alternator::Config cfg;
cfg.content_encoding_decoders.push_back(
    std::make_shared<scylladb::alternator::ZlibContentEncodingDecoder>(
        std::vector<std::string>{"gzip"}));
cfg.content_encoding_decoders.push_back(std::make_shared<ZstdDecoder>());

Testing

  • make test-unit
  • make check
  • cmake -S . -B build-no-zlib-check -DCMAKE_DISABLE_FIND_PACKAGE_ZLIB=TRUE -DALTERNATOR_CLIENT_CPP_ENABLE_AWS=OFF -DCMAKE_CXX_FLAGS="-Wall -Wextra -Werror" && cmake --build build-no-zlib-check --parallel && ctest --test-dir build-no-zlib-check --output-on-failure -E Integration
  • cmake -S . -B build-aws-check -DALTERNATOR_CLIENT_CPP_REQUIRE_AWS=ON fails locally because AWSSDK with the dynamodb component is not installed in this container

@dkropachev
dkropachev force-pushed the dk/driver-626-response-compression branch 4 times, most recently from ea8b8b2 to 6d076f4 Compare July 13, 2026 16:10
@dkropachev
dkropachev force-pushed the dk/driver-626-response-compression branch from 6d076f4 to 180c517 Compare July 13, 2026 16:15
@dkropachev dkropachev self-assigned this Jul 13, 2026
@dkropachev
dkropachev merged commit c7ec328 into main Jul 13, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support for HTTP response compression

1 participant