Line data Source code
1 : #pragma once 2 : 3 : #include "envoy/http/http_server_properties_cache.h" 4 : 5 : #include "source/common/http/conn_pool_base.h" 6 : 7 : namespace Envoy { 8 : namespace Http { 9 : 10 : // An HTTP connection pool which supports both HTTP/1 and HTTP/2 based on ALPN 11 : class HttpConnPoolImplMixed : public HttpConnPoolImplBase { 12 : public: 13 : HttpConnPoolImplMixed( 14 : Event::Dispatcher& dispatcher, Random::RandomGenerator& random_generator, 15 : Upstream::HostConstSharedPtr host, Upstream::ResourcePriority priority, 16 : const Network::ConnectionSocket::OptionsSharedPtr& options, 17 : const Network::TransportSocketOptionsConstSharedPtr& transport_socket_options, 18 : Upstream::ClusterConnectivityState& state, 19 : absl::optional<HttpServerPropertiesCache::Origin> origin, 20 : Http::HttpServerPropertiesCacheSharedPtr http_server_properties_cache) 21 : : HttpConnPoolImplBase(std::move(host), std::move(priority), dispatcher, options, 22 : transport_socket_options, random_generator, state, 23 : {Protocol::Http2, Protocol::Http11}), 24 0 : http_server_properties_cache_(http_server_properties_cache), origin_(origin) {} 25 : 26 : Envoy::ConnectionPool::ActiveClientPtr instantiateActiveClient() override; 27 : CodecClientPtr createCodecClient(Upstream::Host::CreateConnectionData& data) override; 28 : 29 : void onConnected(Envoy::ConnectionPool::ActiveClient& client) override; 30 0 : Http::Protocol protocol() { return protocol_; } 31 : 32 0 : absl::string_view protocolDescription() const override { return "HTTP/1 HTTP/2 ALPN"; } 33 : 34 : private: 35 : // Default to HTTP/1, as servers which don't support ALPN are probably HTTP/1 only. 36 : Http::Protocol protocol_ = Protocol::Http11; 37 : Http::HttpServerPropertiesCacheSharedPtr http_server_properties_cache_; 38 : absl::optional<HttpServerPropertiesCache::Origin> origin_; 39 : }; 40 : 41 : } // namespace Http 42 : } // namespace Envoy