Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions example/ssesvr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ using namespace std;

class EventDispatcher {
public:
EventDispatcher() {
}
EventDispatcher() {}

void wait_event(DataSink *sink) {
unique_lock<mutex> lk(m_);
Expand Down
17 changes: 8 additions & 9 deletions httplib.h
Original file line number Diff line number Diff line change
Expand Up @@ -5987,9 +5987,9 @@ inline ssize_t Stream::write(const std::string &s) {

namespace detail {

inline void calc_actual_timeout(time_t max_timeout_msec,
time_t duration_msec, time_t timeout_sec,
time_t timeout_usec, time_t &actual_timeout_sec,
inline void calc_actual_timeout(time_t max_timeout_msec, time_t duration_msec,
time_t timeout_sec, time_t timeout_usec,
time_t &actual_timeout_sec,
time_t &actual_timeout_usec) {
auto timeout_msec = (timeout_sec * 1000) + (timeout_usec / 1000);

Expand Down Expand Up @@ -8213,8 +8213,7 @@ inline bool ClientImpl::process_socket(
std::function<bool(Stream &strm)> callback) {
return detail::process_client_socket(
socket.sock, read_timeout_sec_, read_timeout_usec_, write_timeout_sec_,
write_timeout_usec_, max_timeout_msec_, start_time,
std::move(callback));
write_timeout_usec_, max_timeout_msec_, start_time, std::move(callback));
}

inline bool ClientImpl::is_ssl() const { return false; }
Expand Down Expand Up @@ -9119,8 +9118,8 @@ inline bool process_client_socket_ssl(
time_t max_timeout_msec,
std::chrono::time_point<std::chrono::steady_clock> start_time, T callback) {
SSLSocketStream strm(sock, ssl, read_timeout_sec, read_timeout_usec,
write_timeout_sec, write_timeout_usec,
max_timeout_msec, start_time);
write_timeout_sec, write_timeout_usec, max_timeout_msec,
start_time);
return callback(strm);
}

Expand Down Expand Up @@ -9735,8 +9734,8 @@ SSLClient::verify_host_with_subject_alt_name(X509 *server_cert) const {

auto type = GEN_DNS;

struct in6_addr addr6{};
struct in_addr addr{};
struct in6_addr addr6 = {};
struct in_addr addr = {};
size_t addr_len = 0;

#ifndef __MINGW32__
Expand Down
11 changes: 6 additions & 5 deletions test/test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3553,9 +3553,11 @@ TEST_F(ServerTest, TooLongRequest) {
}

TEST_F(ServerTest, AlmostTooLongRequest) {
// test for #2046 - URI length check shouldn't include other content on req line
// URI is max URI length, minus 14 other chars in req line (GET, space, leading /, space, HTTP/1.1)
std::string request = "/" + string(CPPHTTPLIB_REQUEST_URI_MAX_LENGTH - 14, 'A');
// test for #2046 - URI length check shouldn't include other content on req
// line URI is max URI length, minus 14 other chars in req line (GET, space,
// leading /, space, HTTP/1.1)
std::string request =
"/" + string(CPPHTTPLIB_REQUEST_URI_MAX_LENGTH - 14, 'A');

auto res = cli_.Get(request.c_str());

Expand Down Expand Up @@ -8283,7 +8285,6 @@ TEST(MaxTimeoutTest, ContentStream) {
Client cli("localhost", PORT);
cli.set_max_timeout(std::chrono::milliseconds(timeout));


{
auto start = std::chrono::steady_clock::now();

Expand Down Expand Up @@ -8345,7 +8346,7 @@ TEST(MaxTimeoutTest, ContentStreamSSL) {
[&, data](size_t offset, size_t length, DataSink &sink) {
const size_t DATA_CHUNK_SIZE = 4;
const auto &d = *data;
std::this_thread::sleep_for(std::chrono::seconds(1));
std::this_thread::sleep_for(std::chrono::seconds(1));
sink.write(&d[offset], std::min(length, DATA_CHUNK_SIZE));
return true;
},
Expand Down
33 changes: 16 additions & 17 deletions test/test_proxy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
using namespace std;
using namespace httplib;

template <typename T>
void ProxyTest(T& cli, bool basic) {
template <typename T> void ProxyTest(T &cli, bool basic) {
cli.set_proxy("localhost", basic ? 3128 : 3129);
auto res = cli.Get("/httpbin/get");
ASSERT_TRUE(res != nullptr);
Expand Down Expand Up @@ -38,7 +37,7 @@ TEST(ProxyTest, SSLDigest) {
// ----------------------------------------------------------------------------

template <typename T>
void RedirectProxyText(T& cli, const char *path, bool basic) {
void RedirectProxyText(T &cli, const char *path, bool basic) {
cli.set_proxy("localhost", basic ? 3128 : 3129);
if (basic) {
cli.set_proxy_basic_auth("hello", "world");
Expand Down Expand Up @@ -100,8 +99,7 @@ TEST(RedirectTest, YouTubeSSLDigest) {

// ----------------------------------------------------------------------------

template <typename T>
void BaseAuthTestFromHTTPWatch(T& cli) {
template <typename T> void BaseAuthTestFromHTTPWatch(T &cli) {
cli.set_proxy("localhost", 3128);
cli.set_proxy_basic_auth("hello", "world");

Expand All @@ -112,19 +110,20 @@ void BaseAuthTestFromHTTPWatch(T& cli) {
}

{
auto res =
cli.Get("/basic-auth/hello/world",
{make_basic_authentication_header("hello", "world")});
auto res = cli.Get("/basic-auth/hello/world",
{make_basic_authentication_header("hello", "world")});
ASSERT_TRUE(res != nullptr);
EXPECT_EQ("{\n \"authenticated\": true, \n \"user\": \"hello\"\n}\n", res->body);
EXPECT_EQ("{\n \"authenticated\": true, \n \"user\": \"hello\"\n}\n",
res->body);
EXPECT_EQ(StatusCode::OK_200, res->status);
}

{
cli.set_basic_auth("hello", "world");
auto res = cli.Get("/basic-auth/hello/world");
ASSERT_TRUE(res != nullptr);
EXPECT_EQ("{\n \"authenticated\": true, \n \"user\": \"hello\"\n}\n", res->body);
EXPECT_EQ("{\n \"authenticated\": true, \n \"user\": \"hello\"\n}\n",
res->body);
EXPECT_EQ(StatusCode::OK_200, res->status);
}

Expand Down Expand Up @@ -158,8 +157,7 @@ TEST(BaseAuthTest, SSL) {
// ----------------------------------------------------------------------------

#ifdef CPPHTTPLIB_OPENSSL_SUPPORT
template <typename T>
void DigestAuthTestFromHTTPWatch(T& cli) {
template <typename T> void DigestAuthTestFromHTTPWatch(T &cli) {
cli.set_proxy("localhost", 3129);
cli.set_proxy_digest_auth("hello", "world");

Expand All @@ -181,7 +179,8 @@ void DigestAuthTestFromHTTPWatch(T& cli) {
for (auto path : paths) {
auto res = cli.Get(path.c_str());
ASSERT_TRUE(res != nullptr);
EXPECT_EQ("{\n \"authenticated\": true, \n \"user\": \"hello\"\n}\n", res->body);
EXPECT_EQ("{\n \"authenticated\": true, \n \"user\": \"hello\"\n}\n",
res->body);
EXPECT_EQ(StatusCode::OK_200, res->status);
}

Expand Down Expand Up @@ -216,8 +215,7 @@ TEST(DigestAuthTest, NoSSL) {

// ----------------------------------------------------------------------------

template <typename T>
void KeepAliveTest(T& cli, bool basic) {
template <typename T> void KeepAliveTest(T &cli, bool basic) {
cli.set_proxy("localhost", basic ? 3128 : 3129);
if (basic) {
cli.set_proxy_basic_auth("hello", "world");
Expand Down Expand Up @@ -249,9 +247,10 @@ void KeepAliveTest(T& cli, bool basic) {
"/httpbin/digest-auth/auth-int/hello/world/MD5",
};

for (auto path: paths) {
for (auto path : paths) {
auto res = cli.Get(path.c_str());
EXPECT_EQ("{\n \"authenticated\": true, \n \"user\": \"hello\"\n}\n", res->body);
EXPECT_EQ("{\n \"authenticated\": true, \n \"user\": \"hello\"\n}\n",
res->body);
EXPECT_EQ(StatusCode::OK_200, res->status);
}
}
Expand Down