11#include <unordered_set>
14#include <userver/engine/task/inherited_variable.hpp>
16USERVER_NAMESPACE_BEGIN
20using BaggageProperties = std::vector<std::pair<std::string, std::optional<std::string>>>;
28 explicit BaggageException(
const std::string& message) : std::runtime_error(message) {}
38 BaggageEntryProperty(std::string_view key, std::optional<std::string_view> value = std::nullopt);
39 std::string ToString()
const;
40 std::optional<std::string> GetValue()
const;
41 std::string GetKey()
const;
44 const std::string_view key_;
45 std::optional<std::string_view> value_;
56 BaggageEntry(std::string_view key, std::string_view value, std::vector<BaggageEntryProperty> properties);
57 std::string ToString()
const;
58 std::string GetValue()
const;
59 std::string GetKey()
const;
73 void ConcatenateWith(std::string& header)
const;
74 const std::string_view key_;
75 std::string_view value_;
76 std::vector<BaggageEntryProperty> properties_;
87 Baggage(std::string header, std::unordered_set<std::string> allowed_keys);
88 Baggage(
const Baggage&)
noexcept;
91 std::string ToString()
const;
110 void AddEntry(std::string key, std::string value, BaggageProperties properties);
121 static std::optional<
BaggageEntryProperty> TryMakeBaggageEntryProperty(std::string_view property);
128 void CreateResultHeader();
130 std::string header_value_;
131 std::unordered_set<std::string> allowed_keys_;
132 std::vector<BaggageEntry> entries_;
136 std::string result_header_;
139 bool is_valid_header_ =
true;
146bool HasInvalidSymbols(
const T& obj) {
147 return std::find_if(obj.begin(), obj.end(), [](
unsigned char x) {
148 return x ==
',' || x ==
';' || x ==
'=' || std::isspace(x);
152inline engine::TaskInheritedVariable<
Baggage> kInheritedBaggage;