Skip to content

Commit c689778

Browse files
committed
fix: Fix a wrapper support issue where the wrapper header didn't properly handle a missing version.
1 parent e62e575 commit c689778

File tree

4 files changed

+26
-3
lines changed

4 files changed

+26
-3
lines changed

contract-tests/data-model/include/data_model/data_model.hpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,13 @@ struct ConfigHooksParams {
143143

144144
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(ConfigHooksParams, hooks);
145145

146+
struct ConfigWrapper {
147+
std::string name;
148+
std::string version;
149+
};
150+
151+
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(ConfigWrapper, name, version);
152+
146153
struct ConfigParams {
147154
std::string credential;
148155
std::optional<uint32_t> startWaitTimeMs;
@@ -156,6 +163,7 @@ struct ConfigParams {
156163
std::optional<ConfigTLSParams> tls;
157164
std::optional<ConfigProxyParams> proxy;
158165
std::optional<ConfigHooksParams> hooks;
166+
std::optional<ConfigWrapper> wrapper;
159167
};
160168

161169
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(ConfigParams,
@@ -170,7 +178,8 @@ NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(ConfigParams,
170178
tags,
171179
tls,
172180
proxy,
173-
hooks);
181+
hooks,
182+
wrapper);
174183

175184
struct ContextSingleParams {
176185
std::optional<std::string> kind;

contract-tests/server-contract-tests/src/entity_manager.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,15 @@ std::optional<std::string> EntityManager::create(ConfigParams const& in) {
145145
}
146146
}
147147

148+
if (in.wrapper) {
149+
if (!in.wrapper->name.empty()) {
150+
config_builder.HttpProperties().WrapperName(in.wrapper->name);
151+
}
152+
if (!in.wrapper->version.empty()) {
153+
config_builder.HttpProperties().WrapperVersion(in.wrapper->version);
154+
}
155+
}
156+
148157
auto config = config_builder.Build();
149158
if (!config) {
150159
LD_LOG(logger_, LogLevel::kWarn)

contract-tests/server-contract-tests/src/main.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ int main(int argc, char* argv[]) {
5050
srv.add_capability("client-prereq-events");
5151
srv.add_capability("evaluation-hooks");
5252
srv.add_capability("track-hooks");
53+
srv.add_capability("wrapper");
5354

5455
net::signal_set signals{ioc, SIGINT, SIGTERM};
5556

libs/common/src/config/http_properties_builder.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,12 @@ template <typename SDK>
133133
built::HttpProperties HttpPropertiesBuilder<SDK>::Build() const {
134134
if (!wrapper_name_.empty()) {
135135
std::map<std::string, std::string> headers_with_wrapper(base_headers_);
136-
headers_with_wrapper["X-LaunchDarkly-Wrapper"] =
137-
wrapper_name_ + "/" + wrapper_version_;
136+
if (wrapper_version_.empty()) {
137+
headers_with_wrapper["X-LaunchDarkly-Wrapper"] = wrapper_name_;
138+
} else {
139+
headers_with_wrapper["X-LaunchDarkly-Wrapper"] =
140+
wrapper_name_ + "/" + wrapper_version_;
141+
}
138142
return {connect_timeout_, read_timeout_, write_timeout_,
139143
response_timeout_, headers_with_wrapper, tls_.Build(), proxy_};
140144
}

0 commit comments

Comments
 (0)