Skip to content

Commit 31d236e

Browse files
committed
DROGON_DISABLE_HTTP2_CLIENT to disable HTTP/2 in client
1 parent 1fde875 commit 31d236e

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

lib/src/HttpClientImpl.cc

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,16 @@ void HttpClientImpl::createTcpClient()
7373
{
7474
// send request;
7575
LOG_TRACE << "Connection established!";
76+
static bool disableHttp2 = []() {
77+
const char *env = std::getenv("DROGON_DISABLE_HTTP2_CLIENT");
78+
if (env != nullptr && std::string(env) == "1")
79+
{
80+
LOG_WARN << "HTTP/2 client disabled by environment "
81+
"variable DROGON_DISABLE_HTTP2_CLIENT";
82+
return true;
83+
}
84+
return false;
85+
}();
7686

7787
auto protocol = connPtr->applicationProtocol();
7888
if (protocol == "http/1.1")
@@ -85,7 +95,7 @@ void HttpClientImpl::createTcpClient()
8595
&thisPtr->bytesReceived_);
8696
thisPtr->httpVersion_ = Version::kHttp11;
8797
}
88-
else if (protocol == "h2")
98+
else if (protocol == "h2" && !disableHttp2)
8999
{
90100
LOG_TRACE << "Select http/2 protocol";
91101
thisPtr->transport_ =

0 commit comments

Comments
 (0)