Skip to content

Commit bbb83d1

Browse files
committed
Removed default parameter values in Client and SSLClient constructors
1 parent 2d4b42b commit bbb83d1

File tree

1 file changed

+33
-10
lines changed

1 file changed

+33
-10
lines changed

httplib.h

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -571,9 +571,13 @@ class Server {
571571

572572
class Client {
573573
public:
574-
explicit Client(const std::string &host, int port = 80,
575-
const std::string &client_cert_path = std::string(),
576-
const std::string &client_key_path = std::string());
574+
explicit Client(const std::string &host);
575+
576+
explicit Client(const std::string &host, int port);
577+
578+
explicit Client(const std::string &host, int port,
579+
const std::string &client_cert_path,
580+
const std::string &client_key_path);
577581

578582
virtual ~Client();
579583

@@ -897,9 +901,13 @@ class SSLServer : public Server {
897901

898902
class SSLClient : public Client {
899903
public:
900-
explicit SSLClient(const std::string &host, int port = 443,
901-
const std::string &client_cert_path = std::string(),
902-
const std::string &client_key_path = std::string());
904+
explicit SSLClient(const std::string &host);
905+
906+
explicit SSLClient(const std::string &host, int port);
907+
908+
explicit SSLClient(const std::string &host, int port,
909+
const std::string &client_cert_path,
910+
const std::string &client_key_path);
903911

904912
explicit SSLClient(const std::string &host, int port, X509 *client_cert,
905913
EVP_PKEY *client_key);
@@ -3786,6 +3794,12 @@ inline bool Server::process_and_close_socket(socket_t sock) {
37863794
}
37873795

37883796
// HTTP client implementation
3797+
inline Client::Client(const std::string &host)
3798+
: Client(host, 80, std::string(), std::string()) {}
3799+
3800+
inline Client::Client(const std::string &host, int port)
3801+
: Client(host, port, std::string(), std::string()) {}
3802+
37893803
inline Client::Client(const std::string &host, int port,
37903804
const std::string &client_cert_path,
37913805
const std::string &client_key_path)
@@ -4845,6 +4859,12 @@ inline bool SSLServer::process_and_close_socket(socket_t sock) {
48454859
}
48464860

48474861
// SSL HTTP client implementation
4862+
inline SSLClient::SSLClient(const std::string &host)
4863+
: SSLClient(host, 443, std::string(), std::string()) {}
4864+
4865+
inline SSLClient::SSLClient(const std::string &host, int port)
4866+
: SSLClient(host, port, std::string(), std::string()) {}
4867+
48484868
inline SSLClient::SSLClient(const std::string &host, int port,
48494869
const std::string &client_cert_path,
48504870
const std::string &client_key_path)
@@ -5101,13 +5121,16 @@ inline bool SSLClient::check_host_name(const char *pattern,
51015121

51025122
class Client2 {
51035123
public:
5104-
explicit Client2(const char *host_and_port,
5105-
const std::string &client_cert_path = std::string(),
5106-
const std::string &client_key_path = std::string()) {
5124+
explicit Client2(const char *scheme_host_port)
5125+
: Client2(scheme_host_port, std::string(), std::string()) {}
5126+
5127+
explicit Client2(const char *scheme_host_port,
5128+
const std::string &client_cert_path,
5129+
const std::string &client_key_path) {
51075130
const static std::regex re(R"(^(https?)://([^:/?#]+)(?::(\d+))?)");
51085131

51095132
std::cmatch m;
5110-
if (std::regex_match(host_and_port, m, re)) {
5133+
if (std::regex_match(scheme_host_port, m, re)) {
51115134
auto scheme = m[1].str();
51125135
auto host = m[2].str();
51135136
auto port_str = m[3].str();

0 commit comments

Comments
 (0)