### Example Customization File for libHttpClient Source: https://github.com/microsoft/libhttpclient/blob/main/README.md An example customization file, hc_settings.props.example, is provided at the root of the repository. ```properties An example customization file hc_settings.props.example can be found at the root of the repository. ``` -------------------------------- ### Standalone Compilation Example for Examples Source: https://github.com/microsoft/libhttpclient/blob/main/Tests/UnitTests/Tests/BufferSize/README.md Compiles the BufferSizeExample.cpp file as a standalone executable. Adjust include paths and library linkage as necessary. ```bash cl Examples\BufferSizeExample.cpp /I"..\..\..\..\..\Include" /link libHttpClient.lib ``` -------------------------------- ### Standalone Compilation Example for Tests Source: https://github.com/microsoft/libhttpclient/blob/main/Tests/UnitTests/Tests/BufferSize/README.md Compiles the BufferSizeTests.cpp file as a standalone executable. Ensure the include paths and library linkage are correct for your environment. ```bash cl BufferSizeTests.cpp /I"..\..\..\..\Include" /link libHttpClient.lib ``` -------------------------------- ### Example Custom HTTP Implementation with Curl Source: https://github.com/microsoft/libhttpclient/blob/main/README.md This snippet refers to an example demonstrating how to implement custom HTTP handling using HCSetHttpCallPerformFunction() and the Curl library. ```markdown * See sample CustomHttpImplWithCurl for an example of how to use this callback to make your own HTTP implementation. ``` -------------------------------- ### Get and Set Build Flags Source: https://github.com/microsoft/libhttpclient/blob/main/Build/libHttpClient.Android/CMakeLists.txt Includes CMake scripts to retrieve and apply build flags for the project. ```cmake include("../libHttpClient.CMake/GetLibHCFlags.cmake") get_libhc_flags(FLAGS FLAGS_DEBUG FLAGS_RELEASE) include("../libHttpClient.CMake/TargetSetFlags.cmake") target_set_flags( "${PROJECT_NAME}" "${FLAGS}" "${FLAGS_DEBUG}" "${FLAGS_RELEASE}" ) ``` -------------------------------- ### Parse JSON String Source: https://github.com/microsoft/libhttpclient/blob/main/Include/json_cpp/Readme.md Example of parsing a JSON string into a web::json::value object. An std::error_code is used to capture any parsing errors. ```cpp std::error_code err; std::wstring exampleString = L"{\"exampleName\":\"exampleValue\"}"; web::json::value jsonConfig = web::json::value::parse(exampleString, err); ``` -------------------------------- ### Get Current Receive Buffer Size Source: https://github.com/microsoft/libhttpclient/blob/main/Tests/UnitTests/Tests/BufferSize/README.md Retrieves the currently set maximum receive buffer size for an HTTP call request. This allows checking the configured buffer size. ```cpp // Get the current buffer size setting size_t currentSize; hr = HCHttpCallRequestGetMaxReceiveBufferSize(call, ¤tSize); ``` -------------------------------- ### Build libHttpClient with Default Configuration Source: https://github.com/microsoft/libhttpclient/blob/main/Build/libHttpClient.Linux/README.md Run the main build script without arguments to generate Release binaries for libcurl, libssl, libcrypto, and libHttpClient.Linux.so. ```bash ./libHttpClient_Linux.bash ``` -------------------------------- ### Assemble Project with Gradle Source: https://github.com/microsoft/libhttpclient/blob/main/Build/libHttpClient.Android.Workspace/README.md Builds all architectures and flavors of the project using Gradle. Use the appropriate command for your shell. ```bash ./gradlew assemble ``` ```cmd gradlew.bat assemble ``` -------------------------------- ### Assemble Project with Shared Libraries Source: https://github.com/microsoft/libhttpclient/blob/main/Build/libHttpClient.Android.Workspace/README.md Builds libHttpClient as a shared library instead of a static library. Use the appropriate command for your shell. ```bash ./gradlew assemble -PBUILD_SHARED_LIBS ``` ```cmd gradlew.bat assemble -PBUILD_SHARED_LIBS ``` -------------------------------- ### Build OpenSSL with Default Configuration Source: https://github.com/microsoft/libhttpclient/blob/main/Build/libHttpClient.Linux/README.md Running openssl_Linux.bash without arguments will generate Release binaries for libssl.a and libcrypto.a. ```bash ./openssl_Linux.bash ``` -------------------------------- ### Configure Shared Library Build Source: https://github.com/microsoft/libhttpclient/blob/main/Build/libHttpClient.Linux/CMakeLists.txt Sets up the project to build a shared library. Links against libcurl, libssl, and libcrypto. ```cmake if (BUILD_SHARED_LIBS) ######################### ### Set up shared lib ### ######################### add_library( "${PROJECT_NAME}" SHARED "${COMMON_SOURCE_FILES}" "${LINUX_SOURCE_FILES}" "${ZLIB_SOURCE_FILES}" ) target_link_libraries("${PROJECT_NAME}" PRIVATE ${LIBCURL_BINARY_PATH} PRIVATE ${LIBSSL_BINARY_PATH} PRIVATE ${LIBCRYPTO_BINARY_PATH} ) else() ######################### ### Set up static lib ### ######################### add_library( "${PROJECT_NAME}" STATIC "${COMMON_SOURCE_FILES}" "${LINUX_SOURCE_FILES}" "${ZLIB_SOURCE_FILES}" ) endif() ``` -------------------------------- ### Build Static libHttpClient Source: https://github.com/microsoft/libhttpclient/blob/main/Build/libHttpClient.Linux/README.md Execute the build script with the -st or --static argument to generate a static library version of libHttpClient. ```bash ./libHttpClient_Linux.bash <-st|--static> ``` -------------------------------- ### Build libHttpClient with Specified Configuration Source: https://github.com/microsoft/libhttpclient/blob/main/Build/libHttpClient.Linux/README.md Use the -c or --config argument to specify whether to build Debug or Release binaries for libssl, libcrypto, libcurl, and libHttpClient.Linux.so. ```bash ./libHttpClient_Linux.bash <-c|--config> ``` -------------------------------- ### Build cURL with Default Configuration Source: https://github.com/microsoft/libhttpclient/blob/main/Build/libHttpClient.Linux/README.md Run the curl_Linux.bash script without arguments to generate a Release binary of libcurl.a. ```bash ./curl_Linux.bash ``` -------------------------------- ### Build OpenSSL with Specified Configuration Source: https://github.com/microsoft/libhttpclient/blob/main/Build/libHttpClient.Linux/README.md Use the -c or --config argument with openssl_Linux.bash to generate Debug or Release binaries for libssl.a and libcrypto.a. ```bash ./openssl_Linux.bash <-c|--config> ``` -------------------------------- ### Configure WebSocket Compression for Linux Build Source: https://github.com/microsoft/libhttpclient/blob/main/Build/libHttpClient.Linux/README.md Control WebSocket compression support in the Linux build using -wc or --websocket-compression to enable, or -nwc|--no-websocket-compression to disable. Compression is negotiated at runtime. ```bash ./libHttpClient_Linux.bash [<-wc|--websocket-compression>] [<-nwc|--no-websocket-compression>] ``` -------------------------------- ### Create Static Library Source: https://github.com/microsoft/libhttpclient/blob/main/Build/libHttpClient.Android/CMakeLists.txt Defines the static library target and adds source files to it. ```cmake add_library( "${PROJECT_NAME}" "${COMMON_SOURCE_FILES}" "${ANDROID_SOURCE_FILES}" "${ZLIB_SOURCE_FILES}" ) ``` -------------------------------- ### Run WebSocket Compression Integration Test Source: https://github.com/microsoft/libhttpclient/blob/main/Build/libHttpClient.Linux/README.md After enabling WebSocket compression (HC_ENABLE_WEBSOCKET_COMPRESSION=ON), run the specific integration test for websocket-compression on Linux from the CMake build directory. ```bash ctest --output-on-failure -R websocket-compression-linux ``` -------------------------------- ### OpenSSL Build Commands for Windows Source: https://github.com/microsoft/libhttpclient/blob/main/External/opensslGeneratedHeaders/win32/README.md Commands to configure and build OpenSSL for Windows using VC-WIN32, without assembly or shared libraries. ```bash perl Configure VC-WIN32 no-asm no-shared nmake ``` -------------------------------- ### Assemble Project without Websockets Support Source: https://github.com/microsoft/libhttpclient/blob/main/Build/libHttpClient.Android.Workspace/README.md Builds the project while skipping libssl and libcrypto, and passing a compiler flag to exclude websockets support. Use the appropriate command for your shell. ```bash ./gradlew assemble -PHC_NOWEBSOCKETS ``` ```cmd gradlew.bat assemble -PHC_NOWEBSOCKETS ``` -------------------------------- ### Customizing libHttpClient Build with hc_settings.props Source: https://github.com/microsoft/libhttpclient/blob/main/README.md This section details build customizations available for libHttpClient when building from source using MSBuild properties defined in an hc_settings.props file. ```markdown * Defining HCNoWebSockets will exclude WebSocket APIs (and all their dependencies) from the libHttpClient library ``` ```markdown * Defining HCNoZlib will exclude compression APIs and prevent libHttpClient from defining Zlib symbols within libHttpClient ``` ```markdown * Defining HCExternalOpenSSL will prevent libHttpClient from referencing our private OpenSSL projects. If this is defined, you will need to manually include your own (compatible) version of OpenSSL when linking. ``` ```markdown * Setting `HCEnableWebSocketCompression` to `true` or `false` controls whether optional built-in WebSocket compression support is compiled into the Win32 and GDK MSBuild builds. When enabled and the required WinTLS dependency is present, the build defines `HC_ENABLE_WEBSOCKET_COMPRESSION`. This property defaults to `true`. ``` ```markdown * Setting `HCEnableGDKXboxWebSocketCompression` to `true` enables that same built-in compression support on GDK Xbox console builds. This property defaults to `false`. ``` ```markdown * The Win32 certificate-validation integration tests are compiled only in `Tests\WebSocketCompression\WebSocketCompressionIntegrationTests.Win32.vcxproj`, which defines `HC_ENABLE_WSS_CERT_STORE_TESTS=1`. Running that integration binary may prompt for Windows confirmation when it adds or removes the temporary test certificate from `CurrentUser\Root`, so it is intended for manual/integration use rather than CI. The default `Tests\WebSocketCompression\WebSocketCompressionTests.Win32.vcxproj` intentionally omits that define and remains popup-free. ``` -------------------------------- ### Initialize Submodules in Existing Clone Source: https://github.com/microsoft/libhttpclient/blob/main/README.md If the repository was already cloned without the --recursive option, use these commands to initialize and update submodules. ```git git submodule sync git submodule update --init --recursive ``` -------------------------------- ### Configure WebSocket Compression Test Executable Source: https://github.com/microsoft/libhttpclient/blob/main/Build/libHttpClient.Linux/CMakeLists.txt Sets up the WebSocketCompressionTests executable for Linux, including source files, include directories, compile definitions, and linked libraries. This configuration is conditional on HC_ENABLE_WEBSOCKET_COMPRESSION and the absence of HC_NOWEBSOCKETS. ```cmake if (HC_ENABLE_WEBSOCKET_COMPRESSION AND NOT HC_NOWEBSOCKETS) if (DEFINED HC_NOZLIB) message(FATAL_ERROR "HC_ENABLE_WEBSOCKET_COMPRESSION requires zlib support") endif() find_package(Threads REQUIRED) add_executable( "WebSocketCompressionTests.Linux" "${PATH_TO_ROOT}/Tests/WebSocketCompression/WebSocketCompressionTests.cpp" "${ZLIB_SOURCE_FILES}" ) target_include_directories( "WebSocketCompressionTests.Linux" PRIVATE "${COMMON_INCLUDE_DIRS}" "${LINUX_INCLUDE_DIRS}" "${ZLIB_INCLUDE_DIRS}" ) target_compile_definitions( "WebSocketCompressionTests.Linux" PRIVATE ASIO_STANDALONE Z_HAVE_UNISTD_H=1 ) target_link_libraries( "WebSocketCompressionTests.Linux" PRIVATE "${PROJECT_NAME}" Threads::Threads ${CMAKE_DL_LIBS} # Required for dlopen/dlsym referenced by linked libcrypto in some configurations ) if (NOT BUILD_SHARED_LIBS) target_link_libraries( "WebSocketCompressionTests.Linux" PRIVATE "${LIBCURL_BINARY_PATH}" "${LIBSSL_BINARY_PATH}" "${LIBCRYPTO_BINARY_PATH}" ) endif() target_set_flags( "WebSocketCompressionTests.Linux" "${FLAGS}" "${FLAGS_DEBUG}" "${FLAGS_RELEASE}" ) add_test( NAME websocket-compression-linux COMMAND "WebSocketCompressionTests.Linux" ) set_tests_properties( websocket-compression-linux PROPERTIES SKIP_RETURN_CODE 125 ) endif() ``` -------------------------------- ### Clean Project with Gradle Source: https://github.com/microsoft/libhttpclient/blob/main/Build/libHttpClient.Android.Workspace/README.md Cleans the project, removing intermediate and output artifacts. Use the appropriate command for your shell. ```bash ./gradlew clean ``` ```cmd gradlew.bat clean ``` -------------------------------- ### Set Include Directories Source: https://github.com/microsoft/libhttpclient/blob/main/Build/libHttpClient.Linux/CMakeLists.txt Configures include directories for the project, including common, Linux-specific, and zlib include paths. ```cmake target_include_directories( "${PROJECT_NAME}" PRIVATE "${COMMON_INCLUDE_DIRS}" "${LINUX_INCLUDE_DIRS}" "${ZLIB_INCLUDE_DIRS}" ) ``` -------------------------------- ### Build cURL with Specified Configuration Source: https://github.com/microsoft/libhttpclient/blob/main/Build/libHttpClient.Linux/README.md Use the -c or --config argument with curl_Linux.bash to generate either Debug or Release binaries of libcurl.a. ```bash ./curl_Linux.bash <-c|--config> ``` -------------------------------- ### Configure Include Directories Source: https://github.com/microsoft/libhttpclient/blob/main/Build/libHttpClient.Linux/CMakeLists.txt Sets the include directories for the Linux test executable. This ensures that necessary headers are found during compilation. ```cmake target_include_directories( "TaskQueueStarvationTests.Linux" PRIVATE "${COMMON_INCLUDE_DIRS}" "${LINUX_INCLUDE_DIRS}" "${PATH_TO_ROOT}/Tests/Shared" ) ``` -------------------------------- ### Build libHttpClient without OpenSSL Source: https://github.com/microsoft/libhttpclient/blob/main/Build/libHttpClient.Linux/README.md Employ the -ns or --nossl flag to skip the generation of libssl.a and libcrypto.a, allowing you to use your own OpenSSL binaries. ```bash ./libHttpClient_Linux.bash <-ns|--nossl> ``` -------------------------------- ### Clone Repository with Submodules Source: https://github.com/microsoft/libhttpclient/blob/main/README.md Use this command when initially cloning the repository to ensure all submodules are included. ```git git clone --recursive https://github.com/Microsoft/libHttpClient.git ``` -------------------------------- ### Link Libraries and Options for Shared Libraries Source: https://github.com/microsoft/libhttpclient/blob/main/Build/libHttpClient.Android/CMakeLists.txt Configures linking for shared libraries, including system libraries and version script options. ```cmake if (BUILD_SHARED_LIBS) target_link_libraries( "${PROJECT_NAME}" PRIVATE log # Following should be moved to target_link_options when available with cmake 3.13 -Wl,--version-script,${CMAKE_CURRENT_SOURCE_DIR}/libHttpClient.Android.map.txt # This causes the linker to emit an error when a version script names a # symbol that is not found, rather than silently ignoring that line. -Wl,--no-undefined-version ) set_target_properties( "${PROJECT_NAME}" PROPERTIES LINK_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/libHttpClient.Android.map.txt ) endif() ``` -------------------------------- ### Set Include Directories for Linux Test Executable Source: https://github.com/microsoft/libhttpclient/blob/main/Build/libHttpClient.Linux/CMakeLists.txt Configures the include directories for the SingleQueuePollStrandTests.Linux executable, including common, Linux-specific, and shared test directories. ```cmake target_include_directories( "SingleQueuePollStrandTests.Linux" PRIVATE "${COMMON_INCLUDE_DIRS}" "${LINUX_INCLUDE_DIRS}" "${PATH_TO_ROOT}/Tests/Shared" ) ``` -------------------------------- ### Apple Xcode Build Configuration for WebSockets Source: https://github.com/microsoft/libhttpclient/blob/main/README.md For Apple Xcode builds, WebSocket-enabled targets define HC_ENABLE_WEBSOCKET_COMPRESSION and include vendored zlib headers by default. ```c For Apple Xcode builds, the websocket-enabled `libHttpClient_iOS` and `libHttpClient_macOS` targets define `HC_ENABLE_WEBSOCKET_COMPRESSION` and include the vendored `External/zlib` headers by default, so built-in compression support is enabled on iOS and macOS as well. ``` -------------------------------- ### Define Common Include Directories Source: https://github.com/microsoft/libhttpclient/blob/main/Build/libHttpClient.Android/CMakeLists.txt Lists common directories to be included during compilation. ```cmake set(COMMON_INCLUDE_DIRS "${PATH_TO_ROOT}/Source" "${PATH_TO_ROOT}/Source/Common" "${PATH_TO_ROOT}/Source/HTTP" "${PATH_TO_ROOT}/Source/Logger" "${PATH_TO_ROOT}/Source/Platform" "${PATH_TO_ROOT}/Include" "${PATH_TO_ROOT}/Include/httpClient" "${PATH_TO_ROOT}/External/asio/asio/include" "${PATH_TO_ROOT}/External/openssl/include" "${PATH_TO_ROOT}/External/websocketpp" ) ``` -------------------------------- ### Set Compile Definitions Source: https://github.com/microsoft/libhttpclient/blob/main/Build/libHttpClient.Linux/CMakeLists.txt Defines Z_HAVE_UNISTD_H=1 for zlib support if HC_NOZLIB is not defined. ```cmake if (NOT DEFINED HC_NOZLIB) target_compile_definitions("${PROJECT_NAME}" PRIVATE Z_HAVE_UNISTD_H=1) endif() ``` -------------------------------- ### Build libHttpClient without cURL Source: https://github.com/microsoft/libhttpclient/blob/main/Build/libHttpClient.Linux/README.md Use the -nc or --nocurl flag to prevent the generation of libcurl.a, useful if you intend to provide your own cURL version. ```bash ./libHttpClient_Linux.bash <-nc|--nocurl> ``` -------------------------------- ### Set Source File Properties Source: https://github.com/microsoft/libhttpclient/blob/main/Build/libHttpClient.Android/CMakeLists.txt Applies compile definitions to specified source files. ```cmake set_source_files_properties( ${ZLIB_SOURCE_FILES} PROPERTIES COMPILE_DEFINITIONS "${ZLIB_COMPILE_DEFINITIONS}" ) ``` -------------------------------- ### Define Android Specific Include Directories Source: https://github.com/microsoft/libhttpclient/blob/main/Build/libHttpClient.Android/CMakeLists.txt Lists include directories specific to the Android build environment. ```cmake set(ANDROID_INCLUDE_DIRS "${PATH_TO_ROOT}/External/opensslGeneratedHeaders/android" ) ``` -------------------------------- ### Set Target Include Directories Source: https://github.com/microsoft/libhttpclient/blob/main/Build/libHttpClient.Android/CMakeLists.txt Specifies private include directories for the library target. ```cmake target_include_directories( "${PROJECT_NAME}" PRIVATE "${COMMON_INCLUDE_DIRS}" "${ANDROID_INCLUDE_DIRS}" "${ZLIB_INCLUDE_DIRS}" ) ``` -------------------------------- ### Include json_cpp Header Source: https://github.com/microsoft/libhttpclient/blob/main/Include/json_cpp/Readme.md Include the necessary header file to use the json_cpp library in your C++ project. ```cpp #include ``` -------------------------------- ### Set C++ Standard Source: https://github.com/microsoft/libhttpclient/blob/main/Build/libHttpClient.Android/CMakeLists.txt Sets the C++ standard to C++17 for the project. ```cmake set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17") ``` -------------------------------- ### Link Libraries for Linux Tests Source: https://github.com/microsoft/libhttpclient/blob/main/Build/libHttpClient.Linux/CMakeLists.txt Links the required libraries to the Linux test executable. This includes the project's own library, Threads, and dynamic linking libraries. ```cmake target_link_libraries( "TaskQueueStarvationTests.Linux" PRIVATE "${PROJECT_NAME}" Threads::Threads ${CMAKE_DL_LIBS} ) ``` -------------------------------- ### Linux CMake Build Customization for WebSockets Source: https://github.com/microsoft/libhttpclient/blob/main/README.md For Linux CMake builds, HC_ENABLE_WEBSOCKET_COMPRESSION is enabled by default. The helper script exposes options to control this behavior. ```bash For Linux CMake builds, `HC_ENABLE_WEBSOCKET_COMPRESSION` is enabled by default. The helper script in `Build\libHttpClient.Linux\libHttpClient_Linux.bash` keeps that default and exposes `-nwc|--no-websocket-compression` as an opt-out, while still accepting `-wc|--websocket-compression` for explicit enablement. ``` -------------------------------- ### Add Linux Single-Port Delayed-Callback Strand Test Executable Source: https://github.com/microsoft/libhttpclient/blob/main/Build/libHttpClient.Linux/CMakeLists.txt Adds the SingleQueuePollStrandTests.Linux executable. This test exercises the STL WaitTimer backend and links against the libHttpClient.Linux target. ```cmake add_executable( "SingleQueuePollStrandTests.Linux" "${PATH_TO_ROOT}/Tests/TaskQueueStarvation/SingleQueuePollStrandRepro.cpp" ) ``` -------------------------------- ### Link Libraries for Linux Test Executable Source: https://github.com/microsoft/libhttpclient/blob/main/Build/libHttpClient.Linux/CMakeLists.txt Links necessary libraries to the SingleQueuePollStrandTests.Linux executable, including the project's main library, Threads, and dynamic linking libraries. ```cmake target_link_libraries( "SingleQueuePollStrandTests.Linux" PRIVATE "${PROJECT_NAME}" Threads::Threads ${CMAKE_DL_LIBS} ) ``` -------------------------------- ### Set Compiler Warnings Source: https://github.com/microsoft/libhttpclient/blob/main/Build/libHttpClient.Linux/CMakeLists.txt Enables compiler warnings for all source files and masks specific warnings for zlib to maintain build output cleanliness. ```cmake # Turn on compiler warnings for all source files. # For zlib, which is external, mask some of the unimportant warnings. This keeps our build output clean without # adding friction to taking zlib updates. If new warnings show up in updates, they should be assessed for impact and # disabled if not considered problematic. target_compile_options("${PROJECT_NAME}" PRIVATE -Werror) set_source_files_properties(${ZLIB_SOURCE_FILES} PROPERTIES COMPILE_OPTIONS "-Wno-implicit-function-declaration") ``` -------------------------------- ### Link Additional Libraries for Static Builds Source: https://github.com/microsoft/libhttpclient/blob/main/Build/libHttpClient.Linux/CMakeLists.txt Conditionally links libcurl, libssl, and libcrypto when building static libraries (NOT BUILD_SHARED_LIBS is true). ```cmake if (NOT BUILD_SHARED_LIBS) target_link_libraries( "SingleQueuePollStrandTests.Linux" PRIVATE "${LIBCURL_BINARY_PATH}" "${LIBSSL_BINARY_PATH}" "${LIBCRYPTO_BINARY_PATH}" ) endif() ``` -------------------------------- ### Add Executable for Linux Tests Source: https://github.com/microsoft/libhttpclient/blob/main/Build/libHttpClient.Linux/CMakeLists.txt Defines the executable target for Linux-based TaskQueue starvation tests. It specifies the source file for the test executable. ```cmake add_executable( "TaskQueueStarvationTests.Linux" "${PATH_TO_ROOT}/Tests/TaskQueueStarvation/TaskQueueStarvationRepro.cpp" ) ``` -------------------------------- ### Set Max Page Size for Android Linker Source: https://github.com/microsoft/libhttpclient/blob/main/Build/libHttpClient.Android/CMakeLists.txt Applies a linker flag to set the maximum page size to 16384 bytes. This is typically used for optimizing memory alignment on 64-bit Android devices. ```cmake # Support 16KB page sizes on 64-bit devices # https://developer.android.com/guide/practices/page-sizes#compile-16-kb-alignment set_property(TARGET "${PROJECT_NAME}" APPEND_STRING PROPERTY LINK_FLAGS " -Wl,-z,max-page-size=16384") ``` -------------------------------- ### Add CTest Source: https://github.com/microsoft/libhttpclient/blob/main/Build/libHttpClient.Linux/CMakeLists.txt Defines a CTest test case for the Linux TaskQueue starvation executable. This allows the test to be discovered and run by the CTest testing framework. ```cmake add_test( NAME taskqueue-starvation-linux COMMAND "TaskQueueStarvationTests.Linux" ) ``` -------------------------------- ### Link Additional Libraries for Static Builds Source: https://github.com/microsoft/libhttpclient/blob/main/Build/libHttpClient.Linux/CMakeLists.txt Conditionally links additional libraries (libcurl, libssl, libcrypto) when building a static library. This is specific to non-shared build configurations. ```cmake if (NOT BUILD_SHARED_LIBS) target_link_libraries( "TaskQueueStarvationTests.Linux" PRIVATE "${LIBCURL_BINARY_PATH}" "${LIBSSL_BINARY_PATH}" "${LIBCRYPTO_BINARY_PATH}" ) endif() ``` -------------------------------- ### Conditional Compile Definitions for Older Android SDKs Source: https://github.com/microsoft/libhttpclient/blob/main/Build/libHttpClient.Android/CMakeLists.txt Adds a compile definition for older Android SDK versions where ftello and fseeko are not available. ```cmake if (ANDROID_PLATFORM_LEVEL LESS 24) list(APPEND ZLIB_COMPILE_DEFINITIONS "USE_FILE32API") endif() ``` -------------------------------- ### Export Project Targets Source: https://github.com/microsoft/libhttpclient/blob/main/Build/libHttpClient.Linux/CMakeLists.txt Exports the project targets to a CMake configuration file, typically used for finding and linking this project in other CMake projects. ```cmake export(TARGETS ${PROJECT_NAME} FILE ${PROJECT_NAME}Config.cmake) ``` -------------------------------- ### Set Compiler Flags Source: https://github.com/microsoft/libhttpclient/blob/main/Build/libHttpClient.Linux/CMakeLists.txt Applies specific compiler flags to the Linux test executable. This includes general, debug, and release flags. ```cmake target_set_flags( "TaskQueueStarvationTests.Linux" "${FLAGS}" "${FLAGS_DEBUG}" "${FLAGS_RELEASE}" ) ``` -------------------------------- ### Set Custom Receive Buffer Size Source: https://github.com/microsoft/libhttpclient/blob/main/Tests/UnitTests/Tests/BufferSize/README.md Sets a custom maximum receive buffer size for an HTTP call request. This must be called before initiating the asynchronous HTTP call. ```cpp // Set a custom receive buffer size size_t bufferSize = 64 * 1024; // 64KB HRESULT hr = HCHttpCallRequestSetMaxReceiveBufferSize(call, bufferSize); ``` -------------------------------- ### Set Compiler Flags for Linux Test Executable Source: https://github.com/microsoft/libhttpclient/blob/main/Build/libHttpClient.Linux/CMakeLists.txt Applies specific compiler flags, including debug and release flags, to the SingleQueuePollStrandTests.Linux executable. ```cmake target_set_flags( "SingleQueuePollStrandTests.Linux" "${FLAGS}" "${FLAGS_DEBUG}" "${FLAGS_RELEASE}" ) ``` -------------------------------- ### Set Test Properties for Labeling Source: https://github.com/microsoft/libhttpclient/blob/main/Build/libHttpClient.Linux/CMakeLists.txt Assigns a label to the CTest test case. This enables CI systems to run all tests with the 'taskqueue' label, simplifying test execution management. ```cmake set_tests_properties( taskqueue-starvation-linux PROPERTIES LABELS "taskqueue" ) ``` -------------------------------- ### Add Linux Test to CTest Source: https://github.com/microsoft/libhttpclient/blob/main/Build/libHttpClient.Linux/CMakeLists.txt Defines the 'taskqueue-poll-strand-linux' test to be run by CTest, specifying the executable to run and assigning it the 'taskqueue' label. ```cmake add_test( NAME taskqueue-poll-strand-linux COMMAND "SingleQueuePollStrandTests.Linux" ) set_tests_properties( taskqueue-poll-strand-linux PROPERTIES LABELS "taskqueue" ) ``` -------------------------------- ### Fix Bash Script Interpreter Error for OpenSSL Build Source: https://github.com/microsoft/libhttpclient/blob/main/Build/libHttpClient.Linux/README.md If the openssl_Linux.bash script produces a '/bin/bash^M: bad interpreter' error, run this sed command to fix line endings before retrying the script. ```bash sed -i -e 's/ $//' openssl_Linux.bash ``` -------------------------------- ### Fix Bash Script Interpreter Error for cURL Build Source: https://github.com/microsoft/libhttpclient/blob/main/Build/libHttpClient.Linux/README.md If the curl_Linux.bash script fails with a '/bin/bash^M: bad interpreter' error, execute this sed command to clean up line endings and then rerun the script. ```bash sed -i -e 's/ $//' curl_Linux.bash ``` -------------------------------- ### Fix Bash Script Interpreter Error Source: https://github.com/microsoft/libhttpclient/blob/main/Build/libHttpClient.Linux/README.md If the bash script encounters a '/bin/bash^M: bad interpreter' error, run this sed command to remove carriage return characters before re-executing the script. ```bash sed -i -e 's/ $//' libHttpClient_Linux.bash ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.