Add ability to get application protocol from AsyncTransportWrapper
[folly.git] / folly / io / async / AsyncSSLSocket.cpp
index e34df5641d6510bf7ccf32f56b01eb8d128a2dc1..101c1fc69edbbcf39019d4dca6c926c56cfac173 100644 (file)
@@ -402,6 +402,15 @@ bool AsyncSSLSocket::connecting() const {
                                      sslState_ == STATE_CONNECTING))));
 }
 
+std::string AsyncSSLSocket::getApplicationProtocol() noexcept {
+  const unsigned char* protoName = nullptr;
+  unsigned protoLength;
+  if (getSelectedNextProtocolNoThrow(&protoName, &protoLength)) {
+    return std::string(reinterpret_cast<const char*>(protoName), protoLength);
+  }
+  return "";
+}
+
 bool AsyncSSLSocket::isEorTrackingEnabled() const {
   const BIO *wb = SSL_get_wbio(ssl_);
   return wb && wb->method == &eorAwareBioMethod;