Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add zstd support #2088

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

davidalo
Copy link
Contributor

@davidalo davidalo commented Mar 5, 2025

No description provided.

@falbrechtskirchinger
Copy link
Contributor

FYI, the broken tests are fixed by #2089 and #2090.

@yhirose
Copy link
Owner

yhirose commented Mar 6, 2025

@davidalo could you rebase your code based on the latest master branch, and fix the format errors reported by 'test/style-check'? Thanks!

test/test.cc Outdated
#else
EXPECT_TRUE(ret == detail::EncodingType::None);
#endif
}

TEST(ParseAcceptEncoding3, AcceptEncoding) {
Request req;
req.set_header("Accept-Encoding", "br;q=1.0, gzip;q=0.8, *;q=0.1");
req.set_header("Accept-Encoding", "br;q=1.0, gzip;q=0.8, gzip;q=0.8, *;q=0.1");
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it a mistake? (gzip;q=0.8 appears twice now.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, good catch. Changed, please check now.

@davidalo
Copy link
Contributor Author

davidalo commented Mar 6, 2025

@davidalo could you rebase your code based on the latest master branch, and fix the format errors reported by 'test/style-check'? Thanks!

Done!

@davidalo
Copy link
Contributor Author

davidalo commented Mar 6, 2025

All tests are passing on my side.

@falbrechtskirchinger
Copy link
Contributor

All tests are passing on my side.

Well, is CI running any of the tests? (Ignoring the internal server error on GH's end.) On Ubuntu and macOS, tests are run through test/Makefile. And on Windows (where we use CMake), we don't have the dependencies (I assume).

Let me know if you need assistance with any of that.

@yhirose
Copy link
Owner

yhirose commented Mar 6, 2025

@davidalo as @falbrechtskirchinger mentioned, the unit tests should run on the GitHub Actions CI. The following lines are for the Brotri support. You can do the same or similar for the zstd support.

BROTLI_DIR = $(PREFIX)/opt/brotli
BROTLI_SUPPORT = -DCPPHTTPLIB_BROTLI_SUPPORT -I$(BROTLI_DIR)/include -L$(BROTLI_DIR)/lib -lbrotlicommon -lbrotlienc -lbrotlidec
TEST_ARGS = gtest/gtest-all.cc gtest/gtest_main.cc $(OPENSSL_SUPPORT) $(ZLIB_SUPPORT) $(BROTLI_SUPPORT) -pthread -lcurl

run: sudo apt-get update && sudo apt-get install -y libbrotli-dev libcurl4-openssl-dev

run: vcpkg install gtest curl zlib brotli

-DHTTPLIB_REQUIRE_BROTLI=ON

Copy link
Contributor

@sum01 sum01 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't forget to add to httplibConfig.cmake.in

Comment on lines +161 to +164
find_package(ZSTD REQUIRED)
set(HTTPLIB_IS_USING_ZSTD TRUE)
elseif(HTTPLIB_USE_ZSTD_IF_AVAILABLE)
find_package(ZSTD QUIET)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

find_package is case sensitive, so use zstd (lower-case) as that's how it's installed with its zstdConfig.cmake file.

elseif(HTTPLIB_USE_ZSTD_IF_AVAILABLE)
find_package(ZSTD QUIET)
# FindZLIB doesn't have a ZLIB_FOUND variable, so check the target.
if(TARGET ZSTD::ZSTD)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The target is zstd::libzstd

@@ -227,6 +242,7 @@ target_link_libraries(${PROJECT_NAME} ${_INTERFACE_OR_PUBLIC}
$<$<BOOL:${HTTPLIB_IS_USING_BROTLI}>:Brotli::encoder>
$<$<BOOL:${HTTPLIB_IS_USING_BROTLI}>:Brotli::decoder>
$<$<BOOL:${HTTPLIB_IS_USING_ZLIB}>:ZLIB::ZLIB>
$<$<BOOL:${HTTPLIB_IS_USING_ZSTD}>:ZSTD::ZSTD>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The target is zstd::libzstd

@@ -4,6 +4,7 @@
* HTTPLIB_USE_OPENSSL_IF_AVAILABLE (default on)
* HTTPLIB_USE_ZLIB_IF_AVAILABLE (default on)
* HTTPLIB_USE_BROTLI_IF_AVAILABLE (default on)
* HTTPLIB_USE_ZSTD_IF_AVAILABLE (default on)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing comment for HTTPLIB_REQUIRE_ZSTD

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants