Skip to content

Added a feature test to auto enable/disable CPPHTTPLIB_USE_NON_BLOCKI… - #2578

Open
TobiasWallner wants to merge 1 commit into
yhirose:masterfrom
TobiasWallner:auto_getaddrinfo
Open

Added a feature test to auto enable/disable CPPHTTPLIB_USE_NON_BLOCKI…#2578
TobiasWallner wants to merge 1 commit into
yhirose:masterfrom
TobiasWallner:auto_getaddrinfo

Conversation

@TobiasWallner

Copy link
Copy Markdown

Summary

Add CMake feature detection for CPPHTTPLIB_USE_NON_BLOCKING_GETADDRINFO on Windows.

When HTTPLIB_USE_NON_BLOCKING_GETADDRINFO is enabled, CMake now checks whether GetAddrInfoExCancel is available before exporting CPPHTTPLIB_USE_NON_BLOCKING_GETADDRINFO through the httplib::httplib target. If the symbol is not available, the non-blocking getaddrinfo support is disabled automatically.

Motivation

Some Windows machines/toolchains do not provide GetAddrInfoExCancel, which causes downstream projects using cpp-httplib via CMake to fail compilation when CPPHTTPLIB_USE_NON_BLOCKING_GETADDRINFO is exported unconditionally.

Previously, consumers had to work around this by manually removing the interface compile definition from httplib::httplib. With this change, cpp-httplib configures itself correctly out of the box.

Testing

Verified on a Windows machine where GetAddrInfoExCancel is unavailable:

  • CMake reports GetAddrInfoExCancel - not found
  • HTTPLIB_IS_USING_NON_BLOCKING_GETADDRINFO is set to FALSE
  • CPPHTTPLIB_USE_NON_BLOCKING_GETADDRINFO is not present on the consumer compile line
  • compiled-library mode builds successfully

@yhirose

yhirose commented Sep 7, 2026

Copy link
Copy Markdown
Owner

@sum01 @jimmy-park @Tachi107 this PR looks good to me. Could you please take a look at it?

@yhirose

yhirose commented Sep 8, 2026

Copy link
Copy Markdown
Owner

@TobiasWallner could you take a look at the CI failures of test / windows with SSL and test /windows without SSL? (You don't need to worry about other failures.)

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.

3 participants