proxygen
proxygen::HTTPDefaultSessionCodecFactory Class Reference

#include <HTTPDefaultSessionCodecFactory.h>

Inheritance diagram for proxygen::HTTPDefaultSessionCodecFactory:
proxygen::HTTPCodecFactory

Public Member Functions

 HTTPDefaultSessionCodecFactory (const AcceptorConfiguration &accConfig)
 
 ~HTTPDefaultSessionCodecFactory () override
 
std::unique_ptr< HTTPCodecgetCodec (const std::string &nextProtocol, TransportDirection direction, bool isTLS) override
 
- Public Member Functions inherited from proxygen::HTTPCodecFactory
 HTTPCodecFactory ()
 
virtual ~HTTPCodecFactory ()
 

Protected Attributes

const AcceptorConfigurationaccConfig_
 
folly::Optional< SPDYVersionalwaysUseSPDYVersion_ {}
 
folly::Optional< bool > alwaysUseHTTP2_ {}
 

Additional Inherited Members

- Static Public Member Functions inherited from proxygen::HTTPCodecFactory
static std::unique_ptr< HTTPCodecgetCodec (CodecProtocol protocol, TransportDirection direction)
 

Detailed Description

Definition at line 18 of file HTTPDefaultSessionCodecFactory.h.

Constructor & Destructor Documentation

proxygen::HTTPDefaultSessionCodecFactory::HTTPDefaultSessionCodecFactory ( const AcceptorConfiguration accConfig)
explicit

Definition at line 19 of file HTTPDefaultSessionCodecFactory.cpp.

References alwaysUseHTTP2_, alwaysUseSPDYVersion_, proxygen::SPDYCodec::getVersion(), proxygen::http2::kProtocolCleartextString, proxygen::AcceptorConfiguration::plaintextProtocol, and version.

21  : accConfig_(accConfig) {
22  // set up codec defaults in the case of plaintext connections
23  auto version = SPDYCodec::getVersion(accConfig.plaintextProtocol);
24  if (version) {
26  } else if (accConfig.plaintextProtocol == http2::kProtocolCleartextString) {
27  alwaysUseHTTP2_ = true;
28  }
29 }
uint8_t getVersion() const
Definition: SPDYCodec.cpp:1023
const std::string kProtocolCleartextString
ProtocolVersion version
proxygen::HTTPDefaultSessionCodecFactory::~HTTPDefaultSessionCodecFactory ( )
inlineoverride

Definition at line 22 of file HTTPDefaultSessionCodecFactory.h.

References getCodec(), and string.

22 {}

Member Function Documentation

std::unique_ptr< HTTPCodec > proxygen::HTTPDefaultSessionCodecFactory::getCodec ( const std::string nextProtocol,
TransportDirection  direction,
bool  isTLS 
)
overridevirtual

Get a codec instance

Implements proxygen::HTTPCodecFactory.

Definition at line 31 of file HTTPDefaultSessionCodecFactory.cpp.

References accConfig_, proxygen::AcceptorConfiguration::allowedPlaintextUpgradeProtocols, alwaysUseHTTP2_, alwaysUseSPDYVersion_, codec, proxygen::SPDYCodec::getVersion(), proxygen::http2::kProtocolDraftString, proxygen::http2::kProtocolExperimentalString, proxygen::http2::kProtocolString, folly::gen::move, proxygen::AcceptorConfiguration::spdyCompressionLevel, proxygen::HTTP1xCodec::supportsNextProtocol(), folly::Optional< Value >::value(), and version.

Referenced by TEST(), and ~HTTPDefaultSessionCodecFactory().

32  {
33  if (!isTLS && alwaysUseSPDYVersion_) {
34  return std::make_unique<SPDYCodec>(direction,
37  } else if (!isTLS && alwaysUseHTTP2_) {
38  return std::make_unique<HTTP2Codec>(direction);
39  } else if (nextProtocol.empty() ||
40  HTTP1xCodec::supportsNextProtocol(nextProtocol)) {
41  auto codec = std::make_unique<HTTP1xCodec>(direction);
42  if (!isTLS) {
43  codec->setAllowedUpgradeProtocols(
45  }
46  return std::move(codec);
47  } else if (auto version = SPDYCodec::getVersion(nextProtocol)) {
48  return std::make_unique<SPDYCodec>(direction, *version,
50  } else if (nextProtocol == http2::kProtocolString ||
51  nextProtocol == http2::kProtocolDraftString ||
52  nextProtocol == http2::kProtocolExperimentalString) {
53  return std::make_unique<HTTP2Codec>(direction);
54  } else {
55  VLOG(2) << "Client requested unrecognized next protocol " << nextProtocol;
56  }
57 
58  return nullptr;
59 }
uint8_t getVersion() const
Definition: SPDYCodec.cpp:1023
const std::string kProtocolString
static bool supportsNextProtocol(const std::string &npn)
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
CodecFactory codec
std::list< std::string > allowedPlaintextUpgradeProtocols
const std::string kProtocolDraftString
const std::string kProtocolExperimentalString
ProtocolVersion version
FOLLY_CPP14_CONSTEXPR const Value & value() const &
Definition: Optional.h:268

Member Data Documentation

const AcceptorConfiguration& proxygen::HTTPDefaultSessionCodecFactory::accConfig_
protected

Definition at line 32 of file HTTPDefaultSessionCodecFactory.h.

Referenced by getCodec().

folly::Optional<bool> proxygen::HTTPDefaultSessionCodecFactory::alwaysUseHTTP2_ {}
protected

Definition at line 34 of file HTTPDefaultSessionCodecFactory.h.

Referenced by getCodec(), and HTTPDefaultSessionCodecFactory().

folly::Optional<SPDYVersion> proxygen::HTTPDefaultSessionCodecFactory::alwaysUseSPDYVersion_ {}
protected

Definition at line 33 of file HTTPDefaultSessionCodecFactory.h.

Referenced by getCodec(), and HTTPDefaultSessionCodecFactory().


The documentation for this class was generated from the following files: