13 #include <boost/algorithm/string/trim.hpp> 15 #include <glog/logging.h> 28 if (protocolStr == http_1_1) {
30 }
else if (protocolStr == spdy_3) {
32 }
else if (protocolStr == spdy_3_1) {
37 }
else if (protocolStr.
find(hq) == 0) {
55 LOG(FATAL) <<
"Unreachable";
60 return protocolStr == http_1_1 ||
61 protocolStr == spdy_3 ||
62 protocolStr == spdy_3_1 ||
65 protocolStr == http_2 ||
95 if (clientUpgrade.empty() || serverUpgrade.empty()) {
100 std::vector<folly::StringPiece> clientProtocols;
101 folly::split(
",", clientUpgrade, clientProtocols,
true );
102 for (
auto& clientProtocol: clientProtocols) {
103 boost::algorithm::trim(clientProtocol);
109 std::vector<folly::StringPiece> serverProtocols;
110 folly::split(
",", serverUpgrade, serverProtocols,
true );
112 for (
auto& testProtocol: serverProtocols) {
114 boost::algorithm::trim(testProtocol);
115 if (std::find(clientProtocols.begin(), clientProtocols.end(),
116 testProtocol) == clientProtocols.end()) {
127 return std::make_pair(protocol, testProtocol.str());
static const folly::Optional< uint8_t > NoPadding
const std::string kProtocolCleartextString
const std::string kProtocolString
size_type find(const_range_type str) const
void split(const Delim &delimiter, const String &input, std::vector< OutputType > &out, bool ignoreEmpty)
bool isHQCodecProtocol(CodecProtocol protocol)
constexpr auto empty(C const &c) -> decltype(c.empty())
folly::Optional< std::pair< CodecProtocol, std::string > > checkForProtocolUpgrade(const std::string &clientUpgrade, const std::string &serverUpgrade, bool serverMode)
const std::string & getCodecProtocolString(CodecProtocol proto)
bool isSpdyCodecProtocol(CodecProtocol protocol)
bool isParallelCodecProtocol(CodecProtocol protocol)
static const folly::Optional< StreamID > NoStream
bool isHTTP2CodecProtocol(CodecProtocol protocol)
CodecProtocol getCodecProtocolFromStr(const std::string &protocolStr)
bool isValidCodecProtocolStr(const std::string &protocolStr)
static const folly::Optional< ExAttributes > NoExAttributes