Line data Source code
1 : #include "source/extensions/http/stateful_session/header/header.h" 2 : 3 : namespace Envoy { 4 : namespace Extensions { 5 : namespace Http { 6 : namespace StatefulSession { 7 : namespace Header { 8 : 9 : void HeaderBasedSessionStateFactory::SessionStateImpl::onUpdate( 10 0 : const Upstream::HostDescription& host, Envoy::Http::ResponseHeaderMap& headers) { 11 0 : absl::string_view host_address = host.address()->asStringView(); 12 0 : if (!upstream_address_.has_value() || host_address != upstream_address_.value()) { 13 0 : const std::string encoded_address = 14 0 : Envoy::Base64::encode(host_address.data(), host_address.length()); 15 0 : headers.setCopy(factory_.getHeaderName(), encoded_address); 16 0 : } 17 0 : } 18 : 19 : HeaderBasedSessionStateFactory::HeaderBasedSessionStateFactory( 20 : const HeaderBasedSessionStateProto& config) 21 0 : : name_(config.name()) { 22 0 : if (config.name().empty()) { 23 0 : throw EnvoyException("Header name cannot be empty for header based stateful sessions"); 24 0 : } 25 0 : } 26 : 27 : } // namespace Header 28 : } // namespace StatefulSession 29 : } // namespace Http 30 : } // namespace Extensions 31 : } // namespace Envoy