Commit 8f06296e authored by Subodh Iyengar's avatar Subodh Iyengar Committed by facebook-github-bot-1

Add ability to get application protocol from AsyncTransportWrapper

Summary: Allows AsyncTransportWrapper's to supply the underlying application
protocol being used, for example using NPN for SSL or some other
generic protocol indication mechanism.

Reviewed By: ranjeeth

Differential Revision: D2614179

fb-gh-sync-id: 2079782bb7d44f898fb14c7df15077209b022424
parent 46bf40d1
......@@ -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;
......
......@@ -273,6 +273,7 @@ class AsyncSSLSocket : public virtual AsyncSocket {
virtual void shutdownWriteNow() override;
virtual bool good() const override;
virtual bool connecting() const override;
virtual std::string getApplicationProtocol() noexcept override;
bool isEorTrackingEnabled() const override;
virtual void setEorTracking(bool track) override;
......
......@@ -533,6 +533,15 @@ class AsyncTransportWrapper : virtual public AsyncTransport,
virtual AsyncTransportWrapper* getWrappedTransport() {
return nullptr;
}
/**
* Return the application protocol being used by the underlying transport
* protocol. This is useful for transports which are used to tunnel other
* protocols.
*/
virtual std::string getApplicationProtocol() noexcept {
return "";
}
};
} // folly
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment