1
#pragma once
2

            
3
#include "envoy/http/http_server_properties_cache.h"
4
#include "envoy/server/overload/overload_manager.h"
5

            
6
#include "source/common/http/conn_pool_base.h"
7

            
8
namespace Envoy {
9
namespace Http {
10

            
11
// An HTTP connection pool which supports both HTTP/1 and HTTP/2 based on ALPN
12
class HttpConnPoolImplMixed : public HttpConnPoolImplBase {
13
public:
14
  HttpConnPoolImplMixed(
15
      Event::Dispatcher& dispatcher, Random::RandomGenerator& random_generator,
16
      Upstream::HostConstSharedPtr host, Upstream::ResourcePriority priority,
17
      const Network::ConnectionSocket::OptionsSharedPtr& options,
18
      const Network::TransportSocketOptionsConstSharedPtr& transport_socket_options,
19
      Upstream::ClusterConnectivityState& state,
20
      absl::optional<HttpServerPropertiesCache::Origin> origin,
21
      Http::HttpServerPropertiesCacheSharedPtr http_server_properties_cache,
22
      Server::OverloadManager& overload_manager)
23
67
      : HttpConnPoolImplBase(std::move(host), std::move(priority), dispatcher, options,
24
67
                             transport_socket_options, random_generator, state,
25
67
                             {Protocol::Http2, Protocol::Http11}, overload_manager),
26
67
        http_server_properties_cache_(http_server_properties_cache), origin_(origin) {}
27

            
28
  Envoy::ConnectionPool::ActiveClientPtr instantiateActiveClient() override;
29
  CodecClientPtr createCodecClient(Upstream::Host::CreateConnectionData& data) override;
30

            
31
  void onConnected(Envoy::ConnectionPool::ActiveClient& client) override;
32
6
  Http::Protocol protocol() { return protocol_; }
33

            
34
1
  absl::string_view protocolDescription() const override { return "HTTP/1 HTTP/2 ALPN"; }
35

            
36
private:
37
  // Default to HTTP/1, as servers which don't support ALPN are probably HTTP/1 only.
38
  Http::Protocol protocol_ = Protocol::Http11;
39
  Http::HttpServerPropertiesCacheSharedPtr http_server_properties_cache_;
40
  absl::optional<HttpServerPropertiesCache::Origin> origin_;
41
};
42

            
43
} // namespace Http
44
} // namespace Envoy