Skip to content

Commit

Permalink
Force gzip/deflate compression binance common api as the result is co…
Browse files Browse the repository at this point in the history
…mpressed
  • Loading branch information
sjanel committed Nov 19, 2024
1 parent f45b0f1 commit 25b82a7
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 44 deletions.
66 changes: 33 additions & 33 deletions CONFIG.md

Large diffs are not rendered by default.

8 changes: 2 additions & 6 deletions src/api/common/include/exchange-permanent-curl-options.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
#include "exchange-query-config.hpp"
#include "permanentcurloptions.hpp"

namespace cct {

namespace api {
namespace cct::api {

class ExchangePermanentCurlOptions {
public:
Expand All @@ -21,6 +19,4 @@ class ExchangePermanentCurlOptions {
const schema::ExchangeQueryConfig &_queryConfig;
};

} // namespace api

} // namespace cct
} // namespace cct::api
2 changes: 2 additions & 0 deletions src/api/common/src/commonapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <utility>

#include "cachedresult.hpp"
#include "cct_const.hpp"
#include "cct_json-container.hpp"
#include "cct_log.hpp"
#include "cct_string.hpp"
Expand Down Expand Up @@ -39,6 +40,7 @@ CommonAPI::CommonAPI(const CoincenterInfo& coincenterInfo, Duration fiatsUpdateF
coincenterInfo.metricGatewayPtr(),
PermanentCurlOptions::Builder()
.setFollowLocation()
.setAcceptedEncoding(kDefaultAcceptEncoding)
.setTooManyErrorsPolicy(PermanentCurlOptions::TooManyErrorsPolicy::kReturnEmptyResponse)
.build(),
coincenterInfo.getRunMode()),
Expand Down
2 changes: 2 additions & 0 deletions src/basic-objects/include/cct_const.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,6 @@ static constexpr int kNbSupportedExchanges = static_cast<int>(std::size(kSupport

static constexpr int kTypicalNbPrivateAccounts = kNbSupportedExchanges;

static constexpr std::string_view kDefaultAcceptEncoding = "gzip,deflate";

} // namespace cct
1 change: 0 additions & 1 deletion src/schema/include/write-json.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#include "cct_exception.hpp"
#include "cct_json-serialization.hpp"
#include "cct_string.hpp"
#include "writer.hpp"

namespace cct {

Expand Down
2 changes: 1 addition & 1 deletion src/schema/src/exchange-config-default.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ struct ExchangeConfigDefault {
},
"exchange": {
"binance": {
"acceptEncoding": "gzip",
"acceptEncoding": "gzip,deflate",
"privateAPIRate": "150ms",
"publicAPIRate": "55ms"
},
Expand Down
6 changes: 3 additions & 3 deletions src/schema/test/exchange-config_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class ExchangeConfigTest : public ::testing::Test {
},
"exchange": {
"binance": {
"acceptEncoding": "gzip",
"acceptEncoding": "gzip,deflate",
"privateAPIRate": "150ms",
"publicAPIRate": "55ms"
},
Expand Down Expand Up @@ -177,7 +177,7 @@ TEST_F(ExchangeConfigTest, DirectRead) {
EXPECT_EQ(exchangeConfigOptional.query.def.updateFrequency->size(), 9);
EXPECT_EQ(exchangeConfigOptional.query.def.validateApiKey, false);
EXPECT_EQ(exchangeConfigOptional.query.exchange.size(), 6);
EXPECT_EQ(exchangeConfigOptional.query.exchange.at(ExchangeNameEnum::binance).acceptEncoding, "gzip");
EXPECT_EQ(exchangeConfigOptional.query.exchange.at(ExchangeNameEnum::binance).acceptEncoding, "gzip,deflate");
}

TEST_F(ExchangeConfigTest, ExchangeValuesShouldOverrideDefault) {
Expand All @@ -190,7 +190,7 @@ TEST_F(ExchangeConfigTest, ExchangeValuesShouldOverrideDefault) {
EXPECT_EQ(allExchangeConfigs[ExchangeNameEnum::binance].asset.allExclude, CurrencyCodeSet{"BQX"});
EXPECT_EQ(allExchangeConfigs[ExchangeNameEnum::kraken].asset.withdrawExclude,
CurrencyCodeSet({"AUD", "CAD", "CHF", "EUR", "GBP", "JPY", "KRW", "USD", "KFEE"}));
EXPECT_EQ(allExchangeConfigs[ExchangeNameEnum::binance].query.acceptEncoding, "gzip");
EXPECT_EQ(allExchangeConfigs[ExchangeNameEnum::binance].query.acceptEncoding, "gzip,deflate");
EXPECT_EQ(allExchangeConfigs[ExchangeNameEnum::binance].query.privateAPIRate.duration,
std::chrono::milliseconds(150));
EXPECT_EQ(allExchangeConfigs[ExchangeNameEnum::binance].query.publicAPIRate.duration, std::chrono::milliseconds(55));
Expand Down

0 comments on commit 25b82a7

Please sign in to comment.