This commit is contained in:
Joel Rosdahl 2023-03-08 23:03:20 +01:00 committed by GitHub
parent 1ebb8412c5
commit 9f7ae0737a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 23 additions and 23 deletions

View file

@ -79,7 +79,7 @@ set(_HTTPLIB_OPENSSL_MIN_VER "1.1.1")
# Allow for a build to require OpenSSL to pass, instead of just being optional # Allow for a build to require OpenSSL to pass, instead of just being optional
option(HTTPLIB_REQUIRE_OPENSSL "Requires OpenSSL to be found & linked, or fails build." OFF) option(HTTPLIB_REQUIRE_OPENSSL "Requires OpenSSL to be found & linked, or fails build." OFF)
option(HTTPLIB_REQUIRE_ZLIB "Requires ZLIB to be found & linked, or fails build." OFF) option(HTTPLIB_REQUIRE_ZLIB "Requires ZLIB to be found & linked, or fails build." OFF)
# Allow for a build to casually enable OpenSSL/ZLIB support, but silenty continue if not found. # Allow for a build to casually enable OpenSSL/ZLIB support, but silently continue if not found.
# Make these options so their automatic use can be specifically disabled (as needed) # Make these options so their automatic use can be specifically disabled (as needed)
option(HTTPLIB_USE_OPENSSL_IF_AVAILABLE "Uses OpenSSL (if available) to enable HTTPS support." ON) option(HTTPLIB_USE_OPENSSL_IF_AVAILABLE "Uses OpenSSL (if available) to enable HTTPS support." ON)
option(HTTPLIB_USE_ZLIB_IF_AVAILABLE "Uses ZLIB (if available) to enable Zlib compression support." ON) option(HTTPLIB_USE_ZLIB_IF_AVAILABLE "Uses ZLIB (if available) to enable Zlib compression support." ON)

View file

@ -800,7 +800,7 @@ private:
ContentReceiver multipart_receiver); ContentReceiver multipart_receiver);
bool read_content_core(Stream &strm, Request &req, Response &res, bool read_content_core(Stream &strm, Request &req, Response &res,
ContentReceiver receiver, ContentReceiver receiver,
MultipartContentHeader mulitpart_header, MultipartContentHeader multipart_header,
ContentReceiver multipart_receiver); ContentReceiver multipart_receiver);
virtual bool process_and_close_socket(socket_t sock); virtual bool process_and_close_socket(socket_t sock);
@ -1150,7 +1150,7 @@ protected:
void copy_settings(const ClientImpl &rhs); void copy_settings(const ClientImpl &rhs);
// Socket endoint information // Socket endpoint information
const std::string host_; const std::string host_;
const int port_; const int port_;
const std::string host_and_port_; const std::string host_and_port_;
@ -5542,7 +5542,7 @@ inline bool Server::read_content_with_content_receiver(
inline bool Server::read_content_core(Stream &strm, Request &req, Response &res, inline bool Server::read_content_core(Stream &strm, Request &req, Response &res,
ContentReceiver receiver, ContentReceiver receiver,
MultipartContentHeader mulitpart_header, MultipartContentHeader multipart_header,
ContentReceiver multipart_receiver) { ContentReceiver multipart_receiver) {
detail::MultipartFormDataParser multipart_form_data_parser; detail::MultipartFormDataParser multipart_form_data_parser;
ContentReceiverWithProgress out; ContentReceiverWithProgress out;
@ -5562,14 +5562,14 @@ inline bool Server::read_content_core(Stream &strm, Request &req, Response &res,
while (pos < n) { while (pos < n) {
auto read_size = (std::min)<size_t>(1, n - pos); auto read_size = (std::min)<size_t>(1, n - pos);
auto ret = multipart_form_data_parser.parse( auto ret = multipart_form_data_parser.parse(
buf + pos, read_size, multipart_receiver, mulitpart_header); buf + pos, read_size, multipart_receiver, multipart_header);
if (!ret) { return false; } if (!ret) { return false; }
pos += read_size; pos += read_size;
} }
return true; return true;
*/ */
return multipart_form_data_parser.parse(buf, n, multipart_receiver, return multipart_form_data_parser.parse(buf, n, multipart_receiver,
mulitpart_header); multipart_header);
}; };
} else { } else {
out = [receiver](const char *buf, size_t n, uint64_t /*off*/, out = [receiver](const char *buf, size_t n, uint64_t /*off*/,
@ -6512,7 +6512,7 @@ inline bool ClientImpl::write_content_with_provider(Stream &strm,
auto is_shutting_down = []() { return false; }; auto is_shutting_down = []() { return false; };
if (req.is_chunked_content_provider_) { if (req.is_chunked_content_provider_) {
// TODO: Brotli suport // TODO: Brotli support
std::unique_ptr<detail::compressor> compressor; std::unique_ptr<detail::compressor> compressor;
#ifdef CPPHTTPLIB_ZLIB_SUPPORT #ifdef CPPHTTPLIB_ZLIB_SUPPORT
if (compress_) { if (compress_) {
@ -7399,7 +7399,7 @@ inline void ClientImpl::stop() {
return; return;
} }
// Otherwise, sitll holding the mutex, we can shut everything down ourselves // Otherwise, still holding the mutex, we can shut everything down ourselves
shutdown_ssl(socket_, true); shutdown_ssl(socket_, true);
shutdown_socket(socket_); shutdown_socket(socket_);
close_socket(socket_); close_socket(socket_);
@ -8142,7 +8142,7 @@ SSLClient::verify_host_with_subject_alt_name(X509 *server_cert) const {
if (alt_names) { if (alt_names) {
auto dsn_matched = false; auto dsn_matched = false;
auto ip_mached = false; auto ip_matched = false;
auto count = sk_GENERAL_NAME_num(alt_names); auto count = sk_GENERAL_NAME_num(alt_names);
@ -8158,14 +8158,14 @@ SSLClient::verify_host_with_subject_alt_name(X509 *server_cert) const {
case GEN_IPADD: case GEN_IPADD:
if (!memcmp(&addr6, name, addr_len) || if (!memcmp(&addr6, name, addr_len) ||
!memcmp(&addr, name, addr_len)) { !memcmp(&addr, name, addr_len)) {
ip_mached = true; ip_matched = true;
} }
break; break;
} }
} }
} }
if (dsn_matched || ip_mached) { ret = true; } if (dsn_matched || ip_matched) { ret = true; }
} }
GENERAL_NAMES_free((STACK_OF(GENERAL_NAME) *)alt_names); GENERAL_NAMES_free((STACK_OF(GENERAL_NAME) *)alt_names);

View file

@ -54,7 +54,7 @@ if(NOT DEFINED httplib_FOUND OR httplib_FOUND)
include("${CMAKE_CURRENT_LIST_DIR}/httplibTargets.cmake") include("${CMAKE_CURRENT_LIST_DIR}/httplibTargets.cmake")
endif() endif()
# Ouputs a "found httplib /usr/include/httplib.h" message when using find_package(httplib) # Outputs a "found httplib /usr/include/httplib.h" message when using find_package(httplib)
include(FindPackageMessage) include(FindPackageMessage)
if(TARGET httplib::httplib) if(TARGET httplib::httplib)
set(HTTPLIB_FOUND TRUE) set(HTTPLIB_FOUND TRUE)

View file

@ -11,7 +11,7 @@
#include <vector> #include <vector>
// Forward declare the "fuzz target" interface. // Forward declare the "fuzz target" interface.
// We deliberately keep this inteface simple and header-free. // We deliberately keep this interface simple and header-free.
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size); extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size);
// It reads all files passed as parameters and feeds their contents // It reads all files passed as parameters and feeds their contents

View file

@ -46,7 +46,7 @@ MultipartFormData &get_file_value(MultipartFormDataItems &files,
return *it; return *it;
#else #else
if (it != files.end()) { return *it; } if (it != files.end()) { return *it; }
throw std::runtime_error("invalid mulitpart form data name error"); throw std::runtime_error("invalid multipart form data name error");
#endif #endif
} }
@ -779,7 +779,7 @@ TEST(DigestAuthTest, FromHTTPWatch_Online) {
} }
// NOTE: Until httpbin.org fixes issue #46, the following test is commented // NOTE: Until httpbin.org fixes issue #46, the following test is commented
// out. Plese see https://httpbin.org/digest-auth/auth/hello/world // out. Please see https://httpbin.org/digest-auth/auth/hello/world
// cli.set_digest_auth("bad", "world"); // cli.set_digest_auth("bad", "world");
// for (auto path : paths) { // for (auto path : paths) {
// auto res = cli.Get(path.c_str()); // auto res = cli.Get(path.c_str());
@ -1778,7 +1778,7 @@ protected:
EXPECT_EQ(text_value.size(), 1); EXPECT_EQ(text_value.size(), 1);
auto &text = text_value[0]; auto &text = text_value[0];
EXPECT_TRUE(text.filename.empty()); EXPECT_TRUE(text.filename.empty());
EXPECT_EQ("defalut text", text.content); EXPECT_EQ("default text", text.content);
} }
{ {
const auto &text1_values = req.get_file_values("multi_text1"); const auto &text1_values = req.get_file_values("multi_text1");
@ -2647,7 +2647,7 @@ TEST_F(ServerTest, MultipartFormData) {
TEST_F(ServerTest, MultipartFormDataMultiFileValues) { TEST_F(ServerTest, MultipartFormDataMultiFileValues) {
MultipartFormDataItems items = { MultipartFormDataItems items = {
{"text", "defalut text", "", ""}, {"text", "default text", "", ""},
{"multi_text1", "aaaaa", "", ""}, {"multi_text1", "aaaaa", "", ""},
{"multi_text1", "bbbbb", "", ""}, {"multi_text1", "bbbbb", "", ""},
@ -3185,7 +3185,7 @@ TEST(GzipDecompressor, ChunkedDecompression) {
{ {
httplib::detail::gzip_decompressor decompressor; httplib::detail::gzip_decompressor decompressor;
// Chunk size is chosen specificaly to have a decompressed chunk size equal // Chunk size is chosen specifically to have a decompressed chunk size equal
// to 16384 bytes 16384 bytes is the size of decompressor output buffer // to 16384 bytes 16384 bytes is the size of decompressor output buffer
size_t chunk_size = 130; size_t chunk_size = 130;
for (size_t chunk_begin = 0; chunk_begin < compressed_data.size(); for (size_t chunk_begin = 0; chunk_begin < compressed_data.size();
@ -3334,7 +3334,7 @@ TEST_F(ServerTest, PostContentReceiver) {
ASSERT_EQ("content", res->body); ASSERT_EQ("content", res->body);
} }
TEST_F(ServerTest, PostMulitpartFilsContentReceiver) { TEST_F(ServerTest, PostMultipartFileContentReceiver) {
MultipartFormDataItems items = { MultipartFormDataItems items = {
{"text1", "text default", "", ""}, {"text1", "text default", "", ""},
{"text2", "aωb", "", ""}, {"text2", "aωb", "", ""},
@ -3349,7 +3349,7 @@ TEST_F(ServerTest, PostMulitpartFilsContentReceiver) {
EXPECT_EQ(200, res->status); EXPECT_EQ(200, res->status);
} }
TEST_F(ServerTest, PostMulitpartPlusBoundary) { TEST_F(ServerTest, PostMultipartPlusBoundary) {
MultipartFormDataItems items = { MultipartFormDataItems items = {
{"text1", "text default", "", ""}, {"text1", "text default", "", ""},
{"text2", "aωb", "", ""}, {"text2", "aωb", "", ""},
@ -3765,10 +3765,10 @@ TEST(ServerRequestParsingTest, ReadHeadersRegexComplexity2) {
"&&&%%%"); "&&&%%%");
} }
TEST(ServerRequestParsingTest, ExcessiveWhitespaceInUnparseableHeaderLine) { TEST(ServerRequestParsingTest, ExcessiveWhitespaceInUnparsableHeaderLine) {
// Make sure this doesn't crash the server. // Make sure this doesn't crash the server.
// In a previous version of the header line regex, the "\r" rendered the line // In a previous version of the header line regex, the "\r" rendered the line
// unparseable and the regex engine repeatedly backtracked, trying to look for // unparsable and the regex engine repeatedly backtracked, trying to look for
// a new position where the leading white space ended and the field value // a new position where the leading white space ended and the field value
// began. // began.
// The crash occurs with libc++ but not libstdc++. // The crash occurs with libc++ but not libstdc++.

View file

@ -193,7 +193,7 @@ void DigestAuthTestFromHTTPWatch(T& cli) {
} }
// NOTE: Until httpbin.org fixes issue #46, the following test is commented // NOTE: Until httpbin.org fixes issue #46, the following test is commented
// out. Plese see https://httpbin.org/digest-auth/auth/hello/world // out. Please see https://httpbin.org/digest-auth/auth/hello/world
// cli.set_digest_auth("bad", "world"); // cli.set_digest_auth("bad", "world");
// for (auto path : paths) { // for (auto path : paths) {
// auto res = cli.Get(path.c_str()); // auto res = cli.Get(path.c_str());