| 946 | } |
| 947 | |
| 948 | std::string ALPNProtocolToString(const AdaptiveProtocolType& protocol) { |
| 949 | butil::StringPiece name = protocol.name(); |
| 950 | // Default use http 1.1 version |
| 951 | if (name.starts_with("http")) { |
| 952 | name.set("http/1.1"); |
| 953 | } |
| 954 | |
| 955 | // ALPN extension uses 1 byte to record the protocol length |
| 956 | // and it's maximum length is 255. |
| 957 | if (name.size() > CHAR_MAX) { |
| 958 | name = name.substr(0, CHAR_MAX); |
| 959 | } |
| 960 | |
| 961 | char length = static_cast<char>(name.size()); |
| 962 | return std::string(&length, 1) + name.data(); |
| 963 | } |
| 964 | |
| 965 | bool BuildALPNProtocolList( |
| 966 | const std::vector<std::string>& alpn_protocols, |