/proc/self/cwd/source/extensions/filters/network/thrift_proxy/metadata.h
Line | Count | Source (jump to first uncovered line) |
1 | | #pragma once |
2 | | |
3 | | #include <algorithm> |
4 | | #include <cstring> |
5 | | #include <list> |
6 | | #include <memory> |
7 | | #include <string> |
8 | | |
9 | | #include "envoy/buffer/buffer.h" |
10 | | #include "envoy/http/header_formatter.h" |
11 | | |
12 | | #include "source/common/common/macros.h" |
13 | | #include "source/common/http/header_map_impl.h" |
14 | | #include "source/extensions/filters/network/thrift_proxy/thrift.h" |
15 | | #include "source/extensions/filters/network/thrift_proxy/tracing.h" |
16 | | |
17 | | #include "absl/strings/str_replace.h" |
18 | | #include "absl/types/optional.h" |
19 | | |
20 | | namespace Envoy { |
21 | | namespace Extensions { |
22 | | namespace NetworkFilters { |
23 | | namespace ThriftProxy { |
24 | | namespace { |
25 | | |
26 | | // See: https://github.com/apache/thrift/commit/e165fa3c85d00cb984f4d9635ed60909a1266ce1 |
27 | | class ThriftCaseHeaderFormatter : public Envoy::Http::StatefulHeaderKeyFormatter { |
28 | | public: |
29 | 0 | ThriftCaseHeaderFormatter() = default; Unexecuted instantiation: client_impl.cc:Envoy::Extensions::NetworkFilters::ThriftProxy::(anonymous namespace)::ThriftCaseHeaderFormatter::ThriftCaseHeaderFormatter() Unexecuted instantiation: shadow_writer_impl.cc:Envoy::Extensions::NetworkFilters::ThriftProxy::(anonymous namespace)::ThriftCaseHeaderFormatter::ThriftCaseHeaderFormatter() Unexecuted instantiation: conn_manager.cc:Envoy::Extensions::NetworkFilters::ThriftProxy::(anonymous namespace)::ThriftCaseHeaderFormatter::ThriftCaseHeaderFormatter() Unexecuted instantiation: twitter_protocol_impl.cc:Envoy::Extensions::NetworkFilters::ThriftProxy::(anonymous namespace)::ThriftCaseHeaderFormatter::ThriftCaseHeaderFormatter() Unexecuted instantiation: decoder.cc:Envoy::Extensions::NetworkFilters::ThriftProxy::(anonymous namespace)::ThriftCaseHeaderFormatter::ThriftCaseHeaderFormatter() |
30 | | |
31 | | // Envoy::Http::StatefulHeaderKeyFormatter |
32 | 0 | std::string format(absl::string_view key) const override { |
33 | 0 | const auto remembered_key_itr = original_header_keys_.find(key); |
34 | 0 | return remembered_key_itr != original_header_keys_.end() ? remembered_key_itr->second |
35 | 0 | : std::string(key); |
36 | 0 | } Unexecuted instantiation: config.cc:Envoy::Extensions::NetworkFilters::ThriftProxy::(anonymous namespace)::ThriftCaseHeaderFormatter::format(std::__1::basic_string_view<char, std::__1::char_traits<char> >) const Unexecuted instantiation: thrift.cc:Envoy::Extensions::NetworkFilters::ThriftProxy::(anonymous namespace)::ThriftCaseHeaderFormatter::format(std::__1::basic_string_view<char, std::__1::char_traits<char> >) const Unexecuted instantiation: client_impl.cc:Envoy::Extensions::NetworkFilters::ThriftProxy::(anonymous namespace)::ThriftCaseHeaderFormatter::format(std::__1::basic_string_view<char, std::__1::char_traits<char> >) const Unexecuted instantiation: router_impl.cc:Envoy::Extensions::NetworkFilters::ThriftProxy::(anonymous namespace)::ThriftCaseHeaderFormatter::format(std::__1::basic_string_view<char, std::__1::char_traits<char> >) const Unexecuted instantiation: router_ratelimit_impl.cc:Envoy::Extensions::NetworkFilters::ThriftProxy::(anonymous namespace)::ThriftCaseHeaderFormatter::format(std::__1::basic_string_view<char, std::__1::char_traits<char> >) const Unexecuted instantiation: shadow_writer_impl.cc:Envoy::Extensions::NetworkFilters::ThriftProxy::(anonymous namespace)::ThriftCaseHeaderFormatter::format(std::__1::basic_string_view<char, std::__1::char_traits<char> >) const Unexecuted instantiation: upstream_request.cc:Envoy::Extensions::NetworkFilters::ThriftProxy::(anonymous namespace)::ThriftCaseHeaderFormatter::format(std::__1::basic_string_view<char, std::__1::char_traits<char> >) const Unexecuted instantiation: conn_manager.cc:Envoy::Extensions::NetworkFilters::ThriftProxy::(anonymous namespace)::ThriftCaseHeaderFormatter::format(std::__1::basic_string_view<char, std::__1::char_traits<char> >) const Unexecuted instantiation: filter_utils.cc:Envoy::Extensions::NetworkFilters::ThriftProxy::(anonymous namespace)::ThriftCaseHeaderFormatter::format(std::__1::basic_string_view<char, std::__1::char_traits<char> >) const Unexecuted instantiation: header_to_metadata_filter.cc:Envoy::Extensions::NetworkFilters::ThriftProxy::(anonymous namespace)::ThriftCaseHeaderFormatter::format(std::__1::basic_string_view<char, std::__1::char_traits<char> >) const Unexecuted instantiation: payload_to_metadata_filter.cc:Envoy::Extensions::NetworkFilters::ThriftProxy::(anonymous namespace)::ThriftCaseHeaderFormatter::format(std::__1::basic_string_view<char, std::__1::char_traits<char> >) const Unexecuted instantiation: auto_protocol_impl.cc:Envoy::Extensions::NetworkFilters::ThriftProxy::(anonymous namespace)::ThriftCaseHeaderFormatter::format(std::__1::basic_string_view<char, std::__1::char_traits<char> >) const Unexecuted instantiation: auto_transport_impl.cc:Envoy::Extensions::NetworkFilters::ThriftProxy::(anonymous namespace)::ThriftCaseHeaderFormatter::format(std::__1::basic_string_view<char, std::__1::char_traits<char> >) const Unexecuted instantiation: compact_protocol_impl.cc:Envoy::Extensions::NetworkFilters::ThriftProxy::(anonymous namespace)::ThriftCaseHeaderFormatter::format(std::__1::basic_string_view<char, std::__1::char_traits<char> >) const Unexecuted instantiation: framed_transport_impl.cc:Envoy::Extensions::NetworkFilters::ThriftProxy::(anonymous namespace)::ThriftCaseHeaderFormatter::format(std::__1::basic_string_view<char, std::__1::char_traits<char> >) const Unexecuted instantiation: header_transport_impl.cc:Envoy::Extensions::NetworkFilters::ThriftProxy::(anonymous namespace)::ThriftCaseHeaderFormatter::format(std::__1::basic_string_view<char, std::__1::char_traits<char> >) const Unexecuted instantiation: twitter_protocol_impl.cc:Envoy::Extensions::NetworkFilters::ThriftProxy::(anonymous namespace)::ThriftCaseHeaderFormatter::format(std::__1::basic_string_view<char, std::__1::char_traits<char> >) const Unexecuted instantiation: binary_protocol_impl.cc:Envoy::Extensions::NetworkFilters::ThriftProxy::(anonymous namespace)::ThriftCaseHeaderFormatter::format(std::__1::basic_string_view<char, std::__1::char_traits<char> >) const Unexecuted instantiation: thrift_object_impl.cc:Envoy::Extensions::NetworkFilters::ThriftProxy::(anonymous namespace)::ThriftCaseHeaderFormatter::format(std::__1::basic_string_view<char, std::__1::char_traits<char> >) const Unexecuted instantiation: unframed_transport_impl.cc:Envoy::Extensions::NetworkFilters::ThriftProxy::(anonymous namespace)::ThriftCaseHeaderFormatter::format(std::__1::basic_string_view<char, std::__1::char_traits<char> >) const Unexecuted instantiation: decoder.cc:Envoy::Extensions::NetworkFilters::ThriftProxy::(anonymous namespace)::ThriftCaseHeaderFormatter::format(std::__1::basic_string_view<char, std::__1::char_traits<char> >) const Unexecuted instantiation: ratelimit.cc:Envoy::Extensions::NetworkFilters::ThriftProxy::(anonymous namespace)::ThriftCaseHeaderFormatter::format(std::__1::basic_string_view<char, std::__1::char_traits<char> >) const Unexecuted instantiation: app_exception_impl.cc:Envoy::Extensions::NetworkFilters::ThriftProxy::(anonymous namespace)::ThriftCaseHeaderFormatter::format(std::__1::basic_string_view<char, std::__1::char_traits<char> >) const |
37 | 0 | void processKey(absl::string_view key) override { |
38 | 0 | std::string s = absl::StrReplaceAll(key, {{std::string(1, '\0'), ""}, {"\n", ""}, {"\r", ""}}); |
39 | 0 | std::transform(s.begin(), s.end(), s.begin(), [](unsigned char c) { return std::tolower(c); }); Unexecuted instantiation: client_impl.cc:Envoy::Extensions::NetworkFilters::ThriftProxy::(anonymous namespace)::ThriftCaseHeaderFormatter::processKey(std::__1::basic_string_view<char, std::__1::char_traits<char> >)::{lambda(unsigned char)#1}::operator()(unsigned char) const Unexecuted instantiation: shadow_writer_impl.cc:Envoy::Extensions::NetworkFilters::ThriftProxy::(anonymous namespace)::ThriftCaseHeaderFormatter::processKey(std::__1::basic_string_view<char, std::__1::char_traits<char> >)::{lambda(unsigned char)#1}::operator()(unsigned char) const Unexecuted instantiation: conn_manager.cc:Envoy::Extensions::NetworkFilters::ThriftProxy::(anonymous namespace)::ThriftCaseHeaderFormatter::processKey(std::__1::basic_string_view<char, std::__1::char_traits<char> >)::{lambda(unsigned char)#1}::operator()(unsigned char) const Unexecuted instantiation: twitter_protocol_impl.cc:Envoy::Extensions::NetworkFilters::ThriftProxy::(anonymous namespace)::ThriftCaseHeaderFormatter::processKey(std::__1::basic_string_view<char, std::__1::char_traits<char> >)::{lambda(unsigned char)#1}::operator()(unsigned char) const Unexecuted instantiation: decoder.cc:Envoy::Extensions::NetworkFilters::ThriftProxy::(anonymous namespace)::ThriftCaseHeaderFormatter::processKey(std::__1::basic_string_view<char, std::__1::char_traits<char> >)::{lambda(unsigned char)#1}::operator()(unsigned char) const |
40 | 0 | original_header_keys_.try_emplace(std::move(s), std::string(key)); |
41 | 0 | } Unexecuted instantiation: config.cc:Envoy::Extensions::NetworkFilters::ThriftProxy::(anonymous namespace)::ThriftCaseHeaderFormatter::processKey(std::__1::basic_string_view<char, std::__1::char_traits<char> >) Unexecuted instantiation: thrift.cc:Envoy::Extensions::NetworkFilters::ThriftProxy::(anonymous namespace)::ThriftCaseHeaderFormatter::processKey(std::__1::basic_string_view<char, std::__1::char_traits<char> >) Unexecuted instantiation: client_impl.cc:Envoy::Extensions::NetworkFilters::ThriftProxy::(anonymous namespace)::ThriftCaseHeaderFormatter::processKey(std::__1::basic_string_view<char, std::__1::char_traits<char> >) Unexecuted instantiation: router_impl.cc:Envoy::Extensions::NetworkFilters::ThriftProxy::(anonymous namespace)::ThriftCaseHeaderFormatter::processKey(std::__1::basic_string_view<char, std::__1::char_traits<char> >) Unexecuted instantiation: router_ratelimit_impl.cc:Envoy::Extensions::NetworkFilters::ThriftProxy::(anonymous namespace)::ThriftCaseHeaderFormatter::processKey(std::__1::basic_string_view<char, std::__1::char_traits<char> >) Unexecuted instantiation: shadow_writer_impl.cc:Envoy::Extensions::NetworkFilters::ThriftProxy::(anonymous namespace)::ThriftCaseHeaderFormatter::processKey(std::__1::basic_string_view<char, std::__1::char_traits<char> >) Unexecuted instantiation: upstream_request.cc:Envoy::Extensions::NetworkFilters::ThriftProxy::(anonymous namespace)::ThriftCaseHeaderFormatter::processKey(std::__1::basic_string_view<char, std::__1::char_traits<char> >) Unexecuted instantiation: conn_manager.cc:Envoy::Extensions::NetworkFilters::ThriftProxy::(anonymous namespace)::ThriftCaseHeaderFormatter::processKey(std::__1::basic_string_view<char, std::__1::char_traits<char> >) Unexecuted instantiation: filter_utils.cc:Envoy::Extensions::NetworkFilters::ThriftProxy::(anonymous namespace)::ThriftCaseHeaderFormatter::processKey(std::__1::basic_string_view<char, std::__1::char_traits<char> >) Unexecuted instantiation: header_to_metadata_filter.cc:Envoy::Extensions::NetworkFilters::ThriftProxy::(anonymous namespace)::ThriftCaseHeaderFormatter::processKey(std::__1::basic_string_view<char, std::__1::char_traits<char> >) Unexecuted instantiation: payload_to_metadata_filter.cc:Envoy::Extensions::NetworkFilters::ThriftProxy::(anonymous namespace)::ThriftCaseHeaderFormatter::processKey(std::__1::basic_string_view<char, std::__1::char_traits<char> >) Unexecuted instantiation: auto_protocol_impl.cc:Envoy::Extensions::NetworkFilters::ThriftProxy::(anonymous namespace)::ThriftCaseHeaderFormatter::processKey(std::__1::basic_string_view<char, std::__1::char_traits<char> >) Unexecuted instantiation: auto_transport_impl.cc:Envoy::Extensions::NetworkFilters::ThriftProxy::(anonymous namespace)::ThriftCaseHeaderFormatter::processKey(std::__1::basic_string_view<char, std::__1::char_traits<char> >) Unexecuted instantiation: compact_protocol_impl.cc:Envoy::Extensions::NetworkFilters::ThriftProxy::(anonymous namespace)::ThriftCaseHeaderFormatter::processKey(std::__1::basic_string_view<char, std::__1::char_traits<char> >) Unexecuted instantiation: framed_transport_impl.cc:Envoy::Extensions::NetworkFilters::ThriftProxy::(anonymous namespace)::ThriftCaseHeaderFormatter::processKey(std::__1::basic_string_view<char, std::__1::char_traits<char> >) Unexecuted instantiation: header_transport_impl.cc:Envoy::Extensions::NetworkFilters::ThriftProxy::(anonymous namespace)::ThriftCaseHeaderFormatter::processKey(std::__1::basic_string_view<char, std::__1::char_traits<char> >) Unexecuted instantiation: twitter_protocol_impl.cc:Envoy::Extensions::NetworkFilters::ThriftProxy::(anonymous namespace)::ThriftCaseHeaderFormatter::processKey(std::__1::basic_string_view<char, std::__1::char_traits<char> >) Unexecuted instantiation: binary_protocol_impl.cc:Envoy::Extensions::NetworkFilters::ThriftProxy::(anonymous namespace)::ThriftCaseHeaderFormatter::processKey(std::__1::basic_string_view<char, std::__1::char_traits<char> >) Unexecuted instantiation: thrift_object_impl.cc:Envoy::Extensions::NetworkFilters::ThriftProxy::(anonymous namespace)::ThriftCaseHeaderFormatter::processKey(std::__1::basic_string_view<char, std::__1::char_traits<char> >) Unexecuted instantiation: unframed_transport_impl.cc:Envoy::Extensions::NetworkFilters::ThriftProxy::(anonymous namespace)::ThriftCaseHeaderFormatter::processKey(std::__1::basic_string_view<char, std::__1::char_traits<char> >) Unexecuted instantiation: decoder.cc:Envoy::Extensions::NetworkFilters::ThriftProxy::(anonymous namespace)::ThriftCaseHeaderFormatter::processKey(std::__1::basic_string_view<char, std::__1::char_traits<char> >) Unexecuted instantiation: ratelimit.cc:Envoy::Extensions::NetworkFilters::ThriftProxy::(anonymous namespace)::ThriftCaseHeaderFormatter::processKey(std::__1::basic_string_view<char, std::__1::char_traits<char> >) Unexecuted instantiation: app_exception_impl.cc:Envoy::Extensions::NetworkFilters::ThriftProxy::(anonymous namespace)::ThriftCaseHeaderFormatter::processKey(std::__1::basic_string_view<char, std::__1::char_traits<char> >) |
42 | 0 | void setReasonPhrase(absl::string_view) override {} Unexecuted instantiation: config.cc:Envoy::Extensions::NetworkFilters::ThriftProxy::(anonymous namespace)::ThriftCaseHeaderFormatter::setReasonPhrase(std::__1::basic_string_view<char, std::__1::char_traits<char> >) Unexecuted instantiation: thrift.cc:Envoy::Extensions::NetworkFilters::ThriftProxy::(anonymous namespace)::ThriftCaseHeaderFormatter::setReasonPhrase(std::__1::basic_string_view<char, std::__1::char_traits<char> >) Unexecuted instantiation: client_impl.cc:Envoy::Extensions::NetworkFilters::ThriftProxy::(anonymous namespace)::ThriftCaseHeaderFormatter::setReasonPhrase(std::__1::basic_string_view<char, std::__1::char_traits<char> >) Unexecuted instantiation: router_impl.cc:Envoy::Extensions::NetworkFilters::ThriftProxy::(anonymous namespace)::ThriftCaseHeaderFormatter::setReasonPhrase(std::__1::basic_string_view<char, std::__1::char_traits<char> >) Unexecuted instantiation: router_ratelimit_impl.cc:Envoy::Extensions::NetworkFilters::ThriftProxy::(anonymous namespace)::ThriftCaseHeaderFormatter::setReasonPhrase(std::__1::basic_string_view<char, std::__1::char_traits<char> >) Unexecuted instantiation: shadow_writer_impl.cc:Envoy::Extensions::NetworkFilters::ThriftProxy::(anonymous namespace)::ThriftCaseHeaderFormatter::setReasonPhrase(std::__1::basic_string_view<char, std::__1::char_traits<char> >) Unexecuted instantiation: upstream_request.cc:Envoy::Extensions::NetworkFilters::ThriftProxy::(anonymous namespace)::ThriftCaseHeaderFormatter::setReasonPhrase(std::__1::basic_string_view<char, std::__1::char_traits<char> >) Unexecuted instantiation: conn_manager.cc:Envoy::Extensions::NetworkFilters::ThriftProxy::(anonymous namespace)::ThriftCaseHeaderFormatter::setReasonPhrase(std::__1::basic_string_view<char, std::__1::char_traits<char> >) Unexecuted instantiation: filter_utils.cc:Envoy::Extensions::NetworkFilters::ThriftProxy::(anonymous namespace)::ThriftCaseHeaderFormatter::setReasonPhrase(std::__1::basic_string_view<char, std::__1::char_traits<char> >) Unexecuted instantiation: header_to_metadata_filter.cc:Envoy::Extensions::NetworkFilters::ThriftProxy::(anonymous namespace)::ThriftCaseHeaderFormatter::setReasonPhrase(std::__1::basic_string_view<char, std::__1::char_traits<char> >) Unexecuted instantiation: payload_to_metadata_filter.cc:Envoy::Extensions::NetworkFilters::ThriftProxy::(anonymous namespace)::ThriftCaseHeaderFormatter::setReasonPhrase(std::__1::basic_string_view<char, std::__1::char_traits<char> >) Unexecuted instantiation: auto_protocol_impl.cc:Envoy::Extensions::NetworkFilters::ThriftProxy::(anonymous namespace)::ThriftCaseHeaderFormatter::setReasonPhrase(std::__1::basic_string_view<char, std::__1::char_traits<char> >) Unexecuted instantiation: auto_transport_impl.cc:Envoy::Extensions::NetworkFilters::ThriftProxy::(anonymous namespace)::ThriftCaseHeaderFormatter::setReasonPhrase(std::__1::basic_string_view<char, std::__1::char_traits<char> >) Unexecuted instantiation: compact_protocol_impl.cc:Envoy::Extensions::NetworkFilters::ThriftProxy::(anonymous namespace)::ThriftCaseHeaderFormatter::setReasonPhrase(std::__1::basic_string_view<char, std::__1::char_traits<char> >) Unexecuted instantiation: framed_transport_impl.cc:Envoy::Extensions::NetworkFilters::ThriftProxy::(anonymous namespace)::ThriftCaseHeaderFormatter::setReasonPhrase(std::__1::basic_string_view<char, std::__1::char_traits<char> >) Unexecuted instantiation: header_transport_impl.cc:Envoy::Extensions::NetworkFilters::ThriftProxy::(anonymous namespace)::ThriftCaseHeaderFormatter::setReasonPhrase(std::__1::basic_string_view<char, std::__1::char_traits<char> >) Unexecuted instantiation: twitter_protocol_impl.cc:Envoy::Extensions::NetworkFilters::ThriftProxy::(anonymous namespace)::ThriftCaseHeaderFormatter::setReasonPhrase(std::__1::basic_string_view<char, std::__1::char_traits<char> >) Unexecuted instantiation: binary_protocol_impl.cc:Envoy::Extensions::NetworkFilters::ThriftProxy::(anonymous namespace)::ThriftCaseHeaderFormatter::setReasonPhrase(std::__1::basic_string_view<char, std::__1::char_traits<char> >) Unexecuted instantiation: thrift_object_impl.cc:Envoy::Extensions::NetworkFilters::ThriftProxy::(anonymous namespace)::ThriftCaseHeaderFormatter::setReasonPhrase(std::__1::basic_string_view<char, std::__1::char_traits<char> >) Unexecuted instantiation: unframed_transport_impl.cc:Envoy::Extensions::NetworkFilters::ThriftProxy::(anonymous namespace)::ThriftCaseHeaderFormatter::setReasonPhrase(std::__1::basic_string_view<char, std::__1::char_traits<char> >) Unexecuted instantiation: decoder.cc:Envoy::Extensions::NetworkFilters::ThriftProxy::(anonymous namespace)::ThriftCaseHeaderFormatter::setReasonPhrase(std::__1::basic_string_view<char, std::__1::char_traits<char> >) Unexecuted instantiation: ratelimit.cc:Envoy::Extensions::NetworkFilters::ThriftProxy::(anonymous namespace)::ThriftCaseHeaderFormatter::setReasonPhrase(std::__1::basic_string_view<char, std::__1::char_traits<char> >) Unexecuted instantiation: app_exception_impl.cc:Envoy::Extensions::NetworkFilters::ThriftProxy::(anonymous namespace)::ThriftCaseHeaderFormatter::setReasonPhrase(std::__1::basic_string_view<char, std::__1::char_traits<char> >) |
43 | 0 | absl::string_view getReasonPhrase() const override { return ""; } Unexecuted instantiation: config.cc:Envoy::Extensions::NetworkFilters::ThriftProxy::(anonymous namespace)::ThriftCaseHeaderFormatter::getReasonPhrase() const Unexecuted instantiation: thrift.cc:Envoy::Extensions::NetworkFilters::ThriftProxy::(anonymous namespace)::ThriftCaseHeaderFormatter::getReasonPhrase() const Unexecuted instantiation: client_impl.cc:Envoy::Extensions::NetworkFilters::ThriftProxy::(anonymous namespace)::ThriftCaseHeaderFormatter::getReasonPhrase() const Unexecuted instantiation: router_impl.cc:Envoy::Extensions::NetworkFilters::ThriftProxy::(anonymous namespace)::ThriftCaseHeaderFormatter::getReasonPhrase() const Unexecuted instantiation: router_ratelimit_impl.cc:Envoy::Extensions::NetworkFilters::ThriftProxy::(anonymous namespace)::ThriftCaseHeaderFormatter::getReasonPhrase() const Unexecuted instantiation: shadow_writer_impl.cc:Envoy::Extensions::NetworkFilters::ThriftProxy::(anonymous namespace)::ThriftCaseHeaderFormatter::getReasonPhrase() const Unexecuted instantiation: upstream_request.cc:Envoy::Extensions::NetworkFilters::ThriftProxy::(anonymous namespace)::ThriftCaseHeaderFormatter::getReasonPhrase() const Unexecuted instantiation: conn_manager.cc:Envoy::Extensions::NetworkFilters::ThriftProxy::(anonymous namespace)::ThriftCaseHeaderFormatter::getReasonPhrase() const Unexecuted instantiation: filter_utils.cc:Envoy::Extensions::NetworkFilters::ThriftProxy::(anonymous namespace)::ThriftCaseHeaderFormatter::getReasonPhrase() const Unexecuted instantiation: header_to_metadata_filter.cc:Envoy::Extensions::NetworkFilters::ThriftProxy::(anonymous namespace)::ThriftCaseHeaderFormatter::getReasonPhrase() const Unexecuted instantiation: payload_to_metadata_filter.cc:Envoy::Extensions::NetworkFilters::ThriftProxy::(anonymous namespace)::ThriftCaseHeaderFormatter::getReasonPhrase() const Unexecuted instantiation: auto_protocol_impl.cc:Envoy::Extensions::NetworkFilters::ThriftProxy::(anonymous namespace)::ThriftCaseHeaderFormatter::getReasonPhrase() const Unexecuted instantiation: auto_transport_impl.cc:Envoy::Extensions::NetworkFilters::ThriftProxy::(anonymous namespace)::ThriftCaseHeaderFormatter::getReasonPhrase() const Unexecuted instantiation: compact_protocol_impl.cc:Envoy::Extensions::NetworkFilters::ThriftProxy::(anonymous namespace)::ThriftCaseHeaderFormatter::getReasonPhrase() const Unexecuted instantiation: framed_transport_impl.cc:Envoy::Extensions::NetworkFilters::ThriftProxy::(anonymous namespace)::ThriftCaseHeaderFormatter::getReasonPhrase() const Unexecuted instantiation: header_transport_impl.cc:Envoy::Extensions::NetworkFilters::ThriftProxy::(anonymous namespace)::ThriftCaseHeaderFormatter::getReasonPhrase() const Unexecuted instantiation: twitter_protocol_impl.cc:Envoy::Extensions::NetworkFilters::ThriftProxy::(anonymous namespace)::ThriftCaseHeaderFormatter::getReasonPhrase() const Unexecuted instantiation: binary_protocol_impl.cc:Envoy::Extensions::NetworkFilters::ThriftProxy::(anonymous namespace)::ThriftCaseHeaderFormatter::getReasonPhrase() const Unexecuted instantiation: thrift_object_impl.cc:Envoy::Extensions::NetworkFilters::ThriftProxy::(anonymous namespace)::ThriftCaseHeaderFormatter::getReasonPhrase() const Unexecuted instantiation: unframed_transport_impl.cc:Envoy::Extensions::NetworkFilters::ThriftProxy::(anonymous namespace)::ThriftCaseHeaderFormatter::getReasonPhrase() const Unexecuted instantiation: decoder.cc:Envoy::Extensions::NetworkFilters::ThriftProxy::(anonymous namespace)::ThriftCaseHeaderFormatter::getReasonPhrase() const Unexecuted instantiation: ratelimit.cc:Envoy::Extensions::NetworkFilters::ThriftProxy::(anonymous namespace)::ThriftCaseHeaderFormatter::getReasonPhrase() const Unexecuted instantiation: app_exception_impl.cc:Envoy::Extensions::NetworkFilters::ThriftProxy::(anonymous namespace)::ThriftCaseHeaderFormatter::getReasonPhrase() const |
44 | | |
45 | | private: |
46 | | absl::flat_hash_map<std::string, std::string> original_header_keys_; |
47 | | }; |
48 | | |
49 | | } // namespace |
50 | | |
51 | | /** |
52 | | * MessageMetadata encapsulates metadata about Thrift messages. The various fields are considered |
53 | | * optional since they may come from either the transport or protocol in some cases. Unless |
54 | | * otherwise noted, accessor methods throw absl::bad_optional_access if the corresponding value has |
55 | | * not been set. |
56 | | */ |
57 | | class MessageMetadata { |
58 | | public: |
59 | | MessageMetadata(bool is_request = true, bool preserve_keys = false) |
60 | 0 | : is_request_(is_request), preserve_keys_(preserve_keys) { |
61 | 0 | if (is_request) { |
62 | 0 | auto request_headers = Http::RequestHeaderMapImpl::create(); |
63 | 0 | if (preserve_keys) { |
64 | 0 | request_headers->setFormatter(std::make_unique<ThriftCaseHeaderFormatter>()); |
65 | 0 | } |
66 | 0 | request_headers_ = std::move(request_headers); |
67 | 0 | } else { |
68 | 0 | auto response_headers = Http::ResponseHeaderMapImpl::create(); |
69 | 0 | if (preserve_keys) { |
70 | 0 | response_headers->setFormatter(std::make_unique<ThriftCaseHeaderFormatter>()); |
71 | 0 | } |
72 | 0 | response_headers_ = std::move(response_headers); |
73 | 0 | } |
74 | 0 | } |
75 | | |
76 | 0 | std::shared_ptr<MessageMetadata> createResponseMetadata() const { |
77 | 0 | ASSERT(is_request_); |
78 | 0 | auto copy = std::make_shared<MessageMetadata>(false, preserve_keys_); |
79 | 0 | copyMembers(copy, false /* do not copy request headers */); |
80 | 0 | return copy; |
81 | 0 | } |
82 | | |
83 | 0 | std::shared_ptr<MessageMetadata> clone() const { |
84 | 0 | auto copy = std::make_shared<MessageMetadata>(isRequest(), preserve_keys_); |
85 | 0 | copyMembers(copy); |
86 | 0 | return copy; |
87 | 0 | } |
88 | | |
89 | 0 | bool hasFrameSize() const { return frame_size_.has_value(); } |
90 | 0 | uint32_t frameSize() const { return frame_size_.value(); } |
91 | 0 | void setFrameSize(uint32_t size) { frame_size_ = size; } |
92 | | |
93 | 0 | bool hasProtocol() const { return proto_.has_value(); } |
94 | 0 | ProtocolType protocol() const { return proto_.value(); } |
95 | 0 | void setProtocol(ProtocolType proto) { proto_ = proto; } |
96 | | |
97 | 0 | bool hasMethodName() const { return method_name_.has_value(); } |
98 | 0 | const std::string& methodName() const { return method_name_.value(); } |
99 | 0 | void setMethodName(const std::string& method_name) { method_name_ = method_name; } |
100 | | |
101 | 0 | bool hasHeaderFlags() const { return header_flags_.has_value(); } |
102 | 0 | int16_t headerFlags() const { return header_flags_.value(); } |
103 | 0 | void setHeaderFlags(int16_t header_flags) { header_flags_ = header_flags; } |
104 | | |
105 | 0 | bool hasSequenceId() const { return seq_id_.has_value(); } |
106 | 0 | int32_t sequenceId() const { return seq_id_.value(); } |
107 | 0 | void setSequenceId(int32_t seq_id) { seq_id_ = seq_id; } |
108 | | |
109 | 0 | bool hasMessageType() const { return msg_type_.has_value(); } |
110 | 0 | MessageType messageType() const { return msg_type_.value(); } |
111 | 0 | void setMessageType(MessageType msg_type) { msg_type_ = msg_type; } |
112 | | |
113 | 0 | bool hasReplyType() const { return reply_type_.has_value(); } |
114 | 0 | ReplyType replyType() const { return reply_type_.value(); } |
115 | 0 | void setReplyType(ReplyType reply_type) { reply_type_ = reply_type; } |
116 | | |
117 | | /** |
118 | | * @return HeaderMap of current headers (never throws) |
119 | | */ |
120 | 0 | const Http::RequestHeaderMap& requestHeaders() const { |
121 | 0 | ASSERT(is_request_); |
122 | 0 | return *request_headers_; |
123 | 0 | } |
124 | 0 | Http::RequestHeaderMap& requestHeaders() { |
125 | 0 | ASSERT(is_request_); |
126 | 0 | return *request_headers_; |
127 | 0 | } |
128 | 0 | const Http::ResponseHeaderMap& responseHeaders() const { |
129 | 0 | ASSERT(!is_request_); |
130 | 0 | return *response_headers_; |
131 | 0 | } |
132 | 0 | Http::ResponseHeaderMap& responseHeaders() { |
133 | 0 | ASSERT(!is_request_); |
134 | 0 | return *response_headers_; |
135 | 0 | } |
136 | | |
137 | | /** |
138 | | * @return SpanList an immutable list of Spans |
139 | | */ |
140 | 0 | const SpanList& spans() const { return spans_; } |
141 | | |
142 | | /** |
143 | | * @return SpanList& a reference to a mutable list of Spans |
144 | | */ |
145 | 0 | SpanList& mutableSpans() { return spans_; } |
146 | | |
147 | 0 | bool hasAppException() const { return app_ex_type_.has_value(); } |
148 | 0 | void setAppException(AppExceptionType app_ex_type, const std::string& message) { |
149 | 0 | app_ex_type_ = app_ex_type; |
150 | 0 | app_ex_msg_ = message; |
151 | 0 | } |
152 | 0 | AppExceptionType appExceptionType() const { return app_ex_type_.value(); } |
153 | 0 | const std::string& appExceptionMessage() const { return app_ex_msg_.value(); } |
154 | | |
155 | 0 | bool isProtocolUpgradeMessage() const { return protocol_upgrade_message_; } |
156 | 0 | void setProtocolUpgradeMessage(bool upgrade_message) { |
157 | 0 | protocol_upgrade_message_ = upgrade_message; |
158 | 0 | } |
159 | | |
160 | 0 | bool isDraining() const { return is_draining_; } |
161 | 0 | void setDraining(bool draining) { is_draining_ = draining; } |
162 | | |
163 | 0 | bool isRequest() const { return is_request_; } |
164 | | |
165 | 0 | absl::optional<int64_t> traceId() const { return trace_id_; } |
166 | 0 | void setTraceId(int64_t trace_id) { trace_id_ = trace_id; } |
167 | | |
168 | 0 | absl::optional<int64_t> traceIdHigh() const { return trace_id_high_; } |
169 | 0 | void setTraceIdHigh(int64_t trace_id_high) { trace_id_high_ = trace_id_high; } |
170 | | |
171 | 0 | absl::optional<int64_t> spanId() const { return span_id_; } |
172 | 0 | void setSpanId(int64_t span_id) { span_id_ = span_id; } |
173 | | |
174 | 0 | absl::optional<int64_t> parentSpanId() const { return parent_span_id_; } |
175 | 0 | void setParentSpanId(int64_t parent_span_id) { parent_span_id_ = parent_span_id; } |
176 | | |
177 | 0 | absl::optional<int64_t> flags() const { return flags_; } |
178 | 0 | void setFlags(int64_t flags) { flags_ = flags; } |
179 | | |
180 | 0 | absl::optional<bool> sampled() const { return sampled_; } |
181 | 0 | void setSampled(bool sampled) { sampled_ = sampled; } |
182 | | |
183 | | private: |
184 | 0 | void copyMembers(std::shared_ptr<MessageMetadata> copy, bool copy_header = true) const { |
185 | 0 | if (hasFrameSize()) { |
186 | 0 | copy->setFrameSize(frameSize()); |
187 | 0 | } |
188 | |
|
189 | 0 | if (hasProtocol()) { |
190 | 0 | copy->setProtocol(protocol()); |
191 | 0 | } |
192 | |
|
193 | 0 | if (hasMethodName()) { |
194 | 0 | copy->setMethodName(methodName()); |
195 | 0 | } |
196 | |
|
197 | 0 | if (hasHeaderFlags()) { |
198 | 0 | copy->setHeaderFlags(headerFlags()); |
199 | 0 | } |
200 | |
|
201 | 0 | if (hasSequenceId()) { |
202 | 0 | copy->setSequenceId(sequenceId()); |
203 | 0 | } |
204 | |
|
205 | 0 | if (hasMessageType()) { |
206 | 0 | copy->setMessageType(messageType()); |
207 | 0 | } |
208 | |
|
209 | 0 | if (hasReplyType()) { |
210 | 0 | copy->setReplyType(replyType()); |
211 | 0 | } |
212 | |
|
213 | 0 | if (copy_header) { |
214 | 0 | if (isRequest()) { |
215 | 0 | Http::HeaderMapImpl::copyFrom(copy->requestHeaders(), requestHeaders()); |
216 | 0 | } else { |
217 | 0 | Http::HeaderMapImpl::copyFrom(copy->responseHeaders(), responseHeaders()); |
218 | 0 | } |
219 | 0 | } |
220 | |
|
221 | 0 | copy->mutableSpans().assign(spans().begin(), spans().end()); |
222 | |
|
223 | 0 | if (hasAppException()) { |
224 | 0 | copy->setAppException(appExceptionType(), appExceptionMessage()); |
225 | 0 | } |
226 | |
|
227 | 0 | copy->setProtocolUpgradeMessage(isProtocolUpgradeMessage()); |
228 | |
|
229 | 0 | auto trace_id = traceId(); |
230 | 0 | if (trace_id.has_value()) { |
231 | 0 | copy->setTraceId(trace_id.value()); |
232 | 0 | } |
233 | |
|
234 | 0 | auto trace_id_high = traceIdHigh(); |
235 | 0 | if (trace_id_high.has_value()) { |
236 | 0 | copy->setTraceIdHigh(trace_id_high.value()); |
237 | 0 | } |
238 | |
|
239 | 0 | auto span_id = spanId(); |
240 | 0 | if (span_id.has_value()) { |
241 | 0 | copy->setSpanId(span_id.value()); |
242 | 0 | } |
243 | |
|
244 | 0 | auto parent_span_id = parentSpanId(); |
245 | 0 | if (parent_span_id.has_value()) { |
246 | 0 | copy->setParentSpanId(parent_span_id.value()); |
247 | 0 | } |
248 | |
|
249 | 0 | auto flags_opt = flags(); |
250 | 0 | if (flags_opt.has_value()) { |
251 | 0 | copy->setFlags(flags_opt.value()); |
252 | 0 | } |
253 | |
|
254 | 0 | auto sampled_opt = sampled(); |
255 | 0 | if (sampled_opt.has_value()) { |
256 | 0 | copy->setSampled(sampled_opt.value()); |
257 | 0 | } |
258 | 0 | } |
259 | | absl::optional<uint32_t> frame_size_{}; |
260 | | absl::optional<ProtocolType> proto_{}; |
261 | | absl::optional<std::string> method_name_{}; |
262 | | absl::optional<int16_t> header_flags_{}; |
263 | | absl::optional<int32_t> seq_id_{}; |
264 | | absl::optional<MessageType> msg_type_{}; |
265 | | absl::optional<ReplyType> reply_type_{}; |
266 | | Http::RequestHeaderMapPtr request_headers_{nullptr}; |
267 | | Http::ResponseHeaderMapPtr response_headers_{nullptr}; |
268 | | absl::optional<AppExceptionType> app_ex_type_; |
269 | | absl::optional<std::string> app_ex_msg_; |
270 | | bool protocol_upgrade_message_{false}; |
271 | | bool is_draining_{false}; |
272 | | SpanList spans_; |
273 | | absl::optional<int64_t> trace_id_; |
274 | | absl::optional<int64_t> trace_id_high_; |
275 | | absl::optional<int64_t> span_id_; |
276 | | absl::optional<int64_t> parent_span_id_; |
277 | | absl::optional<int64_t> flags_; |
278 | | absl::optional<bool> sampled_; |
279 | | const bool is_request_; |
280 | | const bool preserve_keys_; |
281 | | }; |
282 | | |
283 | | using MessageMetadataSharedPtr = std::shared_ptr<MessageMetadata>; |
284 | | |
285 | | /** |
286 | | * Constant Thrift headers. All lower case. |
287 | | */ |
288 | | class HeaderValues { |
289 | | public: |
290 | | const Http::LowerCaseString ClientId{":client-id"}; |
291 | | const Http::LowerCaseString Dest{":dest"}; |
292 | | const Http::LowerCaseString MethodName{":method-name"}; |
293 | | const Http::LowerCaseString Drain{":drain"}; |
294 | | }; |
295 | | using Headers = ConstSingleton<HeaderValues>; |
296 | | |
297 | | } // namespace ThriftProxy |
298 | | } // namespace NetworkFilters |
299 | | } // namespace Extensions |
300 | | } // namespace Envoy |