Skip to content

Commit b7909b3

Browse files
committed
Fixing bug in Asio http_client where if TLS is used and a connection is reused the handshake is performed twice.
1 parent 04a99d3 commit b7909b3

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

Release/src/http/client/http_client_asio.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,8 @@ class asio_context : public request_context, public std::enable_shared_from_this
542542

543543
void write_request()
544544
{
545-
if (m_connection->is_ssl())
545+
// Only perform handshake if a TLS connection and not being reused.
546+
if (m_connection->is_ssl() && !m_connection->is_reused())
546547
{
547548
const auto weakCtx = std::weak_ptr<asio_context>(shared_from_this());
548549
m_connection->async_handshake(boost::asio::ssl::stream_base::client,

Release/tests/functional/http/client/outside_tests.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,22 @@ TEST_FIXTURE(uri_address, outside_google_dot_com)
115115
#endif
116116
});
117117
}
118+
119+
TEST_FIXTURE(uri_address, multiple_https_requests)
120+
{
121+
handle_timeout([&]
122+
{
123+
http_client client(U("https://www.google.com"));
124+
125+
http_response response;
126+
for(int i = 0; i < 5; ++i)
127+
{
128+
response = client.request(methods::GET).get();
129+
VERIFY_ARE_EQUAL(status_codes::OK, response.status_code());
130+
response.content_ready().wait();
131+
}
132+
});
133+
}
118134

119135
TEST_FIXTURE(uri_address, reading_google_stream)
120136
{

0 commit comments

Comments
 (0)