mirror of
https://github.com/yhirose/cpp-httplib.git
synced 2026-10-01 13:12:40 +07:00
Fix #2301
This commit is contained in:
@@ -1751,7 +1751,7 @@ protected:
|
||||
// Socket endpoint information
|
||||
const std::string host_;
|
||||
const int port_;
|
||||
const std::string host_and_port_;
|
||||
std::string host_and_port_;
|
||||
|
||||
// Current open socket
|
||||
Socket socket_;
|
||||
@@ -9874,8 +9874,7 @@ inline ClientImpl::ClientImpl(const std::string &host, int port,
|
||||
const std::string &client_cert_path,
|
||||
const std::string &client_key_path)
|
||||
: host_(detail::escape_abstract_namespace_unix_domain(host)), port_(port),
|
||||
host_and_port_(
|
||||
detail::make_host_and_port_string(host_, port, ClientImpl::is_ssl())),
|
||||
host_and_port_(detail::make_host_and_port_string(host_, port, false)),
|
||||
client_cert_path_(client_cert_path), client_key_path_(client_key_path) {}
|
||||
|
||||
inline ClientImpl::~ClientImpl() {
|
||||
@@ -12696,6 +12695,8 @@ inline SSLClient::SSLClient(const std::string &host, int port,
|
||||
const std::string &client_key_path,
|
||||
const std::string &private_key_password)
|
||||
: ClientImpl(host, port, client_cert_path, client_key_path) {
|
||||
host_and_port_ = detail::make_host_and_port_string(host_, port_, true);
|
||||
|
||||
ctx_ = SSL_CTX_new(TLS_client_method());
|
||||
|
||||
SSL_CTX_set_min_proto_version(ctx_, TLS1_2_VERSION);
|
||||
@@ -12727,6 +12728,8 @@ inline SSLClient::SSLClient(const std::string &host, int port,
|
||||
X509 *client_cert, EVP_PKEY *client_key,
|
||||
const std::string &private_key_password)
|
||||
: ClientImpl(host, port) {
|
||||
host_and_port_ = detail::make_host_and_port_string(host_, port_, true);
|
||||
|
||||
ctx_ = SSL_CTX_new(TLS_client_method());
|
||||
|
||||
detail::split(&host_[0], &host_[host_.size()], '.',
|
||||
|
||||
@@ -10924,6 +10924,18 @@ TEST(MakeHostAndPortStringTest, VariousPatterns) {
|
||||
detail::make_host_and_port_string("example.com", 65536, false));
|
||||
}
|
||||
|
||||
#ifdef CPPHTTPLIB_OPENSSL_SUPPORT
|
||||
TEST(SSLClientHostHeaderTest, Issue2301) {
|
||||
httplib::SSLClient cli("roblox.com", 443);
|
||||
cli.set_follow_location(true);
|
||||
|
||||
auto res = cli.Get("/");
|
||||
|
||||
ASSERT_TRUE(res);
|
||||
EXPECT_EQ(StatusCode::OK_200, res->status);
|
||||
}
|
||||
#endif
|
||||
|
||||
TEST(DirtyDataRequestTest, HeadFieldValueContains_CR_LF_NUL) {
|
||||
Server svr;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user