Skip to content
Merged
Show file tree
Hide file tree
Changes from 34 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
d9cbe4a
add and link libcurl
Neumann-A Jun 10, 2024
d6aafe4
Replace curl executable with libcurl API calls
vicroms Apr 22, 2025
f5a89c7
Fix FindLibCURL for builds wihthout network access
vicroms Sep 2, 2025
5fc4d4e
Merge branch 'main' of https://github.com/microsoft/vcpkg-tool into l…
vicroms Oct 9, 2025
7b40572
Merge branch 'main' of https://github.com/microsoft/vcpkg-tool into l…
vicroms Oct 9, 2025
e7f40e1
Remove winHttp
vicroms Oct 20, 2025
da2529c
Restore progress function
vicroms Oct 20, 2025
2865022
Handle non-dl transfer progress
vicroms Oct 20, 2025
60b90a5
Merge branch 'main' of github.com:Microsoft/vcpkg-tool into link-libcurl
vicroms Oct 22, 2025
dfe1d47
Remove unused WinHttp code
vicroms Oct 23, 2025
8e0bd40
Merge branch 'main' of github.com:Microsoft/vcpkg-tool into link-libcurl
vicroms Oct 23, 2025
245480c
Format and regenerate messages
vicroms Oct 23, 2025
b280137
Fix exepected console output of end-to-end test for multiple authorit…
vicroms Oct 23, 2025
03f06ef
Remove unused parameter
vicroms Oct 23, 2025
1517ce7
Remove unused parameters 2
vicroms Oct 23, 2025
a12a086
Format and regenerate messages
vicroms Oct 23, 2025
293fe4e
Fix curl info read loop
vicroms Oct 24, 2025
e22b475
Fix warnings and remove unused messages
vicroms Oct 24, 2025
022d2b8
Update src/vcpkg/binarycaching.cpp
vicroms Oct 28, 2025
bc7816e
Delete CurlRequestPrivateData (#2)
BillyONeal Oct 30, 2025
4433017
PR comments WIP
vicroms Nov 5, 2025
1daf219
PR comments WIP
vicroms Nov 5, 2025
622f98a
Format and regenerate messages
vicroms Nov 5, 2025
06cb1c3
Merge branch 'main' of github.com:Microsoft/vcpkg-tool into link-libcurl
vicroms Nov 5, 2025
f7172f4
Fix download retry
vicroms Nov 6, 2025
2577dee
More review comments
vicroms Nov 6, 2025
d76569b
Handle response code from file:// downloads/
vicroms Nov 6, 2025
5a2cd88
Update end-to-end test expected output
vicroms Nov 6, 2025
c50352d
Fix download progress
vicroms Nov 6, 2025
e8f878d
Add curl license and notices
vicroms Nov 7, 2025
60dd34d
Fix call to upload metrics
vicroms Nov 7, 2025
9cc1edc
Fix expected output comparison with newer versions of libcurl
vicroms Nov 7, 2025
87b7169
Fix expected output comparison with newer versions of libcurl
vicroms Nov 7, 2025
8e2018b
Merge branch 'link-libcurl' of github.com:vicroms/vcpkg-tool into lin…
vicroms Nov 7, 2025
1c53d79
Apply suggestions from code review
vicroms Nov 10, 2025
fd741eb
More PR comments
vicroms Nov 10, 2025
a9c5782
Disable curl examples and fix out-of-bounds access in retry loop
vicroms Nov 11, 2025
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
5 changes: 5 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ jobs:
uses: github/codeql-action/init@v3
with:
languages: javascript-typescript, c-cpp
- name: Install system libcurl
if: matrix.preset == 'linux-arm64-ci' || matrix.preset == 'linux-ci'
run: |
sudo apt update
sudo apt install -y libcurl4-openssl-dev
Copy link
Member

Choose a reason for hiding this comment

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

It seems wrong that we care about which libcurl flavor we get?

- name: Configure and Build
if: matrix.preset != 'windows-ci'
run: |
Expand Down
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ set(TEST_SCRIPT_ASSET_CACHE_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src/test-script

find_package(fmt REQUIRED)
find_package(CMakeRC REQUIRED)
find_package(LibCURL REQUIRED)

# === Target: locale-resources ===

Expand Down Expand Up @@ -229,6 +230,8 @@ target_compile_definitions(vcpkglib PUBLIC
_FILE_OFFSET_BITS=64
)

target_link_libraries(vcpkglib PUBLIC CURL::libcurl)

if(VCPKG_STANDALONE_BUNDLE_SHA)
target_compile_definitions(vcpkglib PUBLIC
"VCPKG_STANDALONE_BUNDLE_SHA=${VCPKG_STANDALONE_BUNDLE_SHA}"
Expand Down
29 changes: 29 additions & 0 deletions NOTICE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,35 @@ SOFTWARE.
=========================================
END OF CMakeRC NOTICES, INFORMATION, AND LICENSE

curl

%% curl NOTICES, INFORMATION, AND LICENSE BEGIN HERE
=========================================
COPYRIGHT AND PERMISSION NOTICE

Copyright (C) Daniel Stenberg, <[email protected]>, and many
contributors, see the THANKS file.

All rights reserved.

Permission to use, copy, modify, and distribute this software for any purpose
with or without fee is hereby granted, provided that the above copyright
notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
OR OTHER DEALINGS IN THE SOFTWARE.

Except as contained in this notice, the name of a copyright holder shall not
be used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization of the copyright holder.
=========================================
END OF curl NOTICES, INFORMATION, AND LICENSE

The following third party software is incorporated into vcpkg-artifacts:

---------------------------------------------------------
Expand Down
60 changes: 23 additions & 37 deletions azure-pipelines/end-to-end-tests-dir/asset-caching.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ Throw-IfNotFailed
$expected = @(
"A suitable version of cmake was not found \(required v[0-9.]+\)\.",
"Trying to download cmake-[0-9.]+-[^.]+\.(zip|tar\.gz) using asset cache file://$assetCacheRegex/[0-9a-z]+",
"error: curl: \(37\) Couldn't open file [^\n]+",
"error: curl operation failed with error code 37 \((Couldn't|Could not) read a file:\/\/ file\)\.",
"error: Not a transient network error, won't retry download from file://$assetCacheRegex/[0-9a-z]+"
"error: there were no asset cache hits, and x-block-origin blocks trying the authoritative source https://github\.com/Kitware/CMake/releases/download/[^ ]+",
"note: If you are using a proxy, please ensure your proxy settings are correct\.",
"Possible causes are:",
Expand Down Expand Up @@ -111,7 +112,8 @@ if (-not ($actual -match $expected)) {
Refresh-TestRoot
$expected = @(
"^Downloading https://localhost:1234/foobar\.html -> example3\.html",
"error: curl: \(7\) Failed to connect to localhost port 1234( after \d+ ms)?: ((Could not|Couldn't) connect to server|Connection refused)",
"error: curl operation failed with error code 7 \((Couldn't|Could not) connect to server\)\.",
"error: Not a transient network error, won't retry download from https://localhost:1234/foobar\.html",
"note: If you are using a proxy, please ensure your proxy settings are correct\.",
"Possible causes are:",
"1\. You are actually using an HTTP proxy, but setting HTTPS_PROXY variable to ``https//address:port``\.",
Expand All @@ -134,9 +136,11 @@ if (-not ($actual -match $expected)) {
Refresh-TestRoot
$expected = @(
"^Downloading example3\.html, trying https://localhost:1234/foobar\.html",
"error: curl operation failed with error code 7 \((Couldn't|Could not) connect to server\)\.",
"error: Not a transient network error, won't retry download from https://localhost:1234/foobar\.html",
"Trying https://localhost:1235/baz\.html",
"error: curl: \(7\) Failed to connect to localhost port 1234( after \d+ ms)?: ((Could not|Couldn't) connect to server|Connection refused)",
"error: curl: \(7\) Failed to connect to localhost port 1235( after \d+ ms)?: ((Could not|Couldn't) connect to server|Connection refused)",
"error: curl operation failed with error code 7 \((Couldn't|Could not) connect to server\)\.",
"error: Not a transient network error, won't retry download from https://localhost:1235/baz\.html",
"note: If you are using a proxy, please ensure your proxy settings are correct\.",
"Possible causes are:",
"1\. You are actually using an HTTP proxy, but setting HTTPS_PROXY variable to ``https//address:port``\.",
Expand Down Expand Up @@ -188,42 +192,20 @@ if (-not ($actual -match $expected)) {
}

# ... also with multiple authoritative URLs
if ($IsWindows) {
# WinHTTP
Refresh-TestRoot
$expected = @(
"^Downloading example3\.html, trying https://nonexistent\.example\.com",
"warning: Download https://nonexistent\.example\.com failed -- retrying after 1000ms",
"warning: Download https://nonexistent\.example\.com failed -- retrying after 2000ms",
"warning: Download https://nonexistent\.example\.com failed -- retrying after 4000ms",
"Trying https://raw\.githubusercontent\.com/microsoft/vcpkg-tool/1767aaee7b229c609f7ad5cf2f57b6a6cc309fb8/LICENSE\.txt",
"Successfully downloaded example3\.html",
"$"
) -join "`n"

$actual = Run-VcpkgAndCaptureOutput @commonArgs x-download "$TestDownloadsRoot/example3.html" --sha512 65077997890f66f6041bb3284bb7b88e27631411ccbc253201ca4e00c4bcc58c0d77edffda4975498797cc10772c7fd68fbeb13cc4ac493a3471a9d49e5b6f24 --url https://nonexistent.example.com --url https://raw.githubusercontent.com/microsoft/vcpkg-tool/1767aaee7b229c609f7ad5cf2f57b6a6cc309fb8/LICENSE.txt
Throw-IfFailed
if (-not ($actual -match $expected)) {
throw "Failure: azurl (no), x-block-origin (no), asset-cache (n/a), download (succeed)"
}
}

# Force curl with --header
Refresh-TestRoot
$expected = @(
"^Downloading example3\.html, trying https://nonexistent\.example\.com",
"warning: (Problem : timeout\.|Transient problem: timeout) Will retry in 1 seconds?\. 3 retries left\.",
"warning: (Problem : timeout\.|Transient problem: timeout) Will retry in \d+ seconds?\. 2 retries left\.",
"warning: (Problem : timeout\.|Transient problem: timeout) Will retry in \d+ seconds?\. 1 (retries|retry) left\.",
"Trying https://raw\.githubusercontent\.com/microsoft/vcpkg-tool/1767aaee7b229c609f7ad5cf2f57b6a6cc309fb8/LICENSE\.txt",
"error: curl operation failed with error code 6 \((Couldn't|Could not) resolve (hostname|host name)\)\.",
"error: Not a transient network error, won't retry download from https://nonexistent\.example\.com",
"Trying https://raw\.githubusercontent\.com/microsoft/vcpkg-tool/1767aaee7b229c609f7ad5cf2f57b6a6cc309fb8/LICENSE\.txt"
"Successfully downloaded example3\.html",
"$"
) -join "`n"

$actual = Run-VcpkgAndCaptureOutput @commonArgs x-download "$TestDownloadsRoot/example3.html" --sha512 65077997890f66f6041bb3284bb7b88e27631411ccbc253201ca4e00c4bcc58c0d77edffda4975498797cc10772c7fd68fbeb13cc4ac493a3471a9d49e5b6f24 --url https://nonexistent.example.com --url https://raw.githubusercontent.com/microsoft/vcpkg-tool/1767aaee7b229c609f7ad5cf2f57b6a6cc309fb8/LICENSE.txt --header "Cache-Control: no-cache"
Throw-IfFailed
if (-not ($actual -match $expected)) {
throw "Failure: azurl (no), x-block-origin (no), asset-cache (n/a), download (succeed)"
throw "Failure: azurl (no), x-block-origin (no), asset-cache (n/a), download (succeed), headers (cache-control)"
}

# azurl (no), x-block-origin (yes), asset-cache (n/a), download (n/a)
Expand All @@ -247,8 +229,10 @@ Refresh-TestRoot
$expected = @(
"^Trying to download example3\.html using asset cache file://$assetCacheRegex/[0-9a-z]+",
"Asset cache miss; trying authoritative source https://localhost:1234/foobar\.html",
"error: curl: \(37\) Couldn't open file [^\n]+",
"error: curl: \(7\) Failed to connect to localhost port 1234( after \d+ ms)?: ((Could not|Couldn't) connect to server|Connection refused)",
"error: curl operation failed with error code 37 \((Couldn't|Could not) read a file:// file\)\.",
"error: Not a transient network error, won't retry download from file://$assetCacheRegex/[0-9a-z]+",
"error: curl operation failed with error code 7 \((Couldn't|Could not) connect to server\)\.",
"error: Not a transient network error, won't retry download from https://localhost:1234/foobar\.html",
"note: If you are using a proxy, please ensure your proxy settings are correct\.",
"Possible causes are:",
"1\. You are actually using an HTTP proxy, but setting HTTPS_PROXY variable to ``https//address:port``\.",
Expand Down Expand Up @@ -307,7 +291,11 @@ if (-not ($actual -match $expected)) {
$expected = @(
"^Trying to download example3\.html using asset cache file://$assetCacheRegex/[0-9a-z]+",
"Asset cache miss; trying authoritative source https://raw\.githubusercontent\.com/microsoft/vcpkg-tool/1767aaee7b229c609f7ad5cf2f57b6a6cc309fb8/LICENSE\.txt",
"error: curl: \(37\) Couldn't open file [^\n]+",
"error: curl operation failed with error code 37 \((Couldn't|Could not) read a file:// file\)\.",
"error: Not a transient network error, won't retry download from file://$assetCacheRegex/[0-9a-z]+",
"[^\n]+example3\.html\.\d+\.part: error: download from https://raw\.githubusercontent\.com/microsoft/vcpkg-tool/1767aaee7b229c609f7ad5cf2f57b6a6cc309fb8/LICENSE\.txt had an unexpected hash",
"note: Expected: d06b93c883f8126a04589937a884032df031b05518eed9d433efb6447834df2596aebd500d69b8283e5702d988ed49655ae654c1683c7a4ae58bfa6b92f2b73b",
"note: Actual : 65077997890f66f6041bb3284bb7b88e27631411ccbc253201ca4e00c4bcc58c0d77edffda4975498797cc10772c7fd68fbeb13cc4ac493a3471a9d49e5b6f24",
"note: If you are using a proxy, please ensure your proxy settings are correct\.",
"Possible causes are:",
"1\. You are actually using an HTTP proxy, but setting HTTPS_PROXY variable to ``https//address:port``\.",
Expand All @@ -317,9 +305,6 @@ $expected = @(
"The value set by your proxy might be wrong, or have same ``https://`` prefix issue\.",
"3\. Your proxy's remote server is out of service\.",
"If you believe this is not a temporary download server failure and vcpkg needs to be changed to download this file from a different location, please submit an issue to https://github\.com/Microsoft/vcpkg/issues",
"[^\n]+example3\.html\.\d+\.part: error: download from https://raw\.githubusercontent\.com/microsoft/vcpkg-tool/1767aaee7b229c609f7ad5cf2f57b6a6cc309fb8/LICENSE\.txt had an unexpected hash",
"note: Expected: d06b93c883f8126a04589937a884032df031b05518eed9d433efb6447834df2596aebd500d69b8283e5702d988ed49655ae654c1683c7a4ae58bfa6b92f2b73b",
"note: Actual : 65077997890f66f6041bb3284bb7b88e27631411ccbc253201ca4e00c4bcc58c0d77edffda4975498797cc10772c7fd68fbeb13cc4ac493a3471a9d49e5b6f24",
"$"
) -join "`n"
$actual = Run-VcpkgAndCaptureOutput @commonArgs x-download "$TestDownloadsRoot/example3.html" --sha512 d06b93c883f8126a04589937a884032df031b05518eed9d433efb6447834df2596aebd500d69b8283e5702d988ed49655ae654c1683c7a4ae58bfa6b92f2b73b --url https://raw.githubusercontent.com/microsoft/vcpkg-tool/1767aaee7b229c609f7ad5cf2f57b6a6cc309fb8/LICENSE.txt "--x-asset-sources=x-azurl,file://$AssetCache,,readwrite"
Expand Down Expand Up @@ -369,7 +354,8 @@ if (-not ($actual -match $expected)) {
Refresh-TestRoot
$expected = @(
"^Trying to download example3\.html using asset cache file://$assetCacheRegex/[0-9a-z]+",
"error: curl: \(37\) Couldn't open file [^\n]+",
"error: curl operation failed with error code 37 \((Couldn't|Could not) read a file:// file\)\.",
"error: Not a transient network error, won't retry download from file://$assetCacheRegex/[0-9a-z]+",
"error: there were no asset cache hits, and x-block-origin blocks trying the authoritative source https://raw\.githubusercontent\.com/microsoft/vcpkg-tool/1767aaee7b229c609f7ad5cf2f57b6a6cc309fb8/LICENSE\.txt",
"note: or https://alternate\.example\.com",
"note: If you are using a proxy, please ensure your proxy settings are correct\.",
Expand Down
13 changes: 13 additions & 0 deletions cgmanifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,19 @@
},
"DevelopmentDependency": false,
"DependencyRoots": []
},
{
"Component": {
"Type": "other",
"other": {
"name": "curl",
"version": "8.17.0",
"downloadUrl": "https://github.com/curl/curl/archive/refs/tags/curl-8_17_0.tar.gz",
"hash": "88ab4b7aac12b26a6ad32fb0e1a9675288a45894438cb031102ef5d4ab6b33c2bc99cae0c70b71bdfa12eb49762827e2490555114c5eb4a6876b95e1f2a4eb74"
}
},
"DevelopmentDependency": false,
"DependencyRoots": []
}
]
}
94 changes: 94 additions & 0 deletions cmake/FindLibCURL.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
if (WIN32)
option(VCPKG_DEPENDENCY_EXTERNAL_LIBCURL "Use an external version of the libcurl library" OFF)
else()
option(VCPKG_DEPENDENCY_EXTERNAL_LIBCURL "Use an external version of the libcurl library" ON)
endif()

if(POLICY CMP0135)
cmake_policy(SET CMP0135 NEW)
endif()

if (VCPKG_DEPENDENCY_EXTERNAL_LIBCURL)
find_package(CURL REQUIRED)
return()
endif()

# This option exists to allow the URI to be replaced with a Microsoft-internal URI in official
# builds which have restricted internet access; see azure-pipelines/signing.yml
# Note that the SHA512 is the same, so vcpkg-tool contributors need not be concerned that we built
# with different content.
if(NOT VCPKG_LIBCURL_URL)
set(VCPKG_LIBCURL_URL "https://github.com/curl/curl/releases/download/curl-8_17_0/curl-8.17.0.tar.gz")
endif()

include(FetchContent)
FetchContent_Declare(
Copy link
Member

Choose a reason for hiding this comment

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

Since curl is a nontrivial build should we consider trying to host ourselves rather than using FetchContent for this case? Our existing other dependencies don't really have meaningful builds which is why we never opened that can of worms.

LibCURL
URL "${VCPKG_LIBCURL_URL}"
URL_HASH "SHA512=88ab4b7aac12b26a6ad32fb0e1a9675288a45894438cb031102ef5d4ab6b33c2bc99cae0c70b71bdfa12eb49762827e2490555114c5eb4a6876b95e1f2a4eb74"
)

if(NOT LibCURL_FIND_REQUIRED)
message(FATAL_ERROR "LibCURL must be REQUIRED")
endif()

# This is in function() so no need to backup the variables
function(get_libcurl)
set(BUILD_CURL_EXE OFF)
set(BUILD_LIBCURL_DOCS OFF)
set(BUILD_MISC_DOCS OFF)
set(BUILD_SHARED_LIBS OFF)
set(CURL_ENABLE_EXPORT_TARGET OFF)
set(CURL_USE_LIBSSH2 OFF)
set(CURL_USE_LIBPSL OFF)
if (WIN32)
set(CURL_USE_SCHANNEL ON)
endif()
set(ENABLE_CURL_MANUAL OFF)
set(ENABLE_UNICODE ON)
set(PICKY_COMPILER OFF)
set(USE_NGHTTP2 OFF)
set(USE_LIBIDN2 OFF)
set(CMAKE_DISABLE_FIND_PACKAGE_Perl ON)
set(CMAKE_DISABLE_FIND_PACKAGE_ZLIB ON)
set(CMAKE_DISABLE_FIND_PACKAGE_LibPSL ON)
set(CMAKE_DISABLE_FIND_PACKAGE_LibSSH2 ON)
set(CMAKE_DISABLE_FIND_PACKAGE_Brotli ON)
set(CMAKE_DISABLE_FIND_PACKAGE_Zstd ON)
Comment on lines +55 to +59
Copy link
Member

Choose a reason for hiding this comment

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

Another reason to consider hosting ourselves rather than FetchContent would be to more easily support ZLIB for Content-encoding: deflate or gzip.

set(CMAKE_DISABLE_FIND_PACKAGE_NGHTTP2 ON)
set(CMAKE_DISABLE_FIND_PACKAGE_Libidn2 ON)
if(MSVC)
string(APPEND CMAKE_C_FLAGS " /wd6101")
string(APPEND CMAKE_C_FLAGS " /wd6011")
string(APPEND CMAKE_C_FLAGS " /wd6054")
#string(APPEND CMAKE_C_FLAGS " /wd6240")
#string(APPEND CMAKE_C_FLAGS " /wd6239")
string(APPEND CMAKE_C_FLAGS " /wd6287")
string(APPEND CMAKE_C_FLAGS " /wd6323")
string(APPEND CMAKE_C_FLAGS " /wd6385")
string(APPEND CMAKE_C_FLAGS " /wd6387")
string(APPEND CMAKE_C_FLAGS " /wd28182")
#string(APPEND CMAKE_C_FLAGS " /wd28183")
string(APPEND CMAKE_C_FLAGS " /wd28251")
string(APPEND CMAKE_C_FLAGS " /wd28301")
else()
string(APPEND CMAKE_C_FLAGS " -Wno-error")
endif()
FetchContent_MakeAvailable(LibCURL)
endfunction()

get_libcurl()

if(NOT TARGET CURL::libcurl)
if(TARGET libcurl_static)
add_library(CURL::libcurl ALIAS libcurl_static)
target_compile_definitions(libcurl_static INTERFACE CURL_STATICLIB)
elseif(TARGET libcurl)
add_library(CURL::libcurl ALIAS libcurl)
if(NOT BUILD_SHARED_LIBS)
target_compile_definitions(libcurl INTERFACE CURL_STATICLIB)
endif()
else()
message(FATAL_ERROR "After FetchContent_MakeAvailable(LibCURL) no suitable curl target (libcurl or libcurl_static) was found.")
endif()
endif()
5 changes: 5 additions & 0 deletions include/vcpkg/base/contractual-constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -590,4 +590,9 @@ namespace vcpkg
inline constexpr StringLiteral StatusInstalled = "installed";
inline constexpr StringLiteral StatusNotInstalled = "not-installed";
inline constexpr StringLiteral StatusPurge = "purge";

// App Insights JSON response fields
inline constexpr StringLiteral AppInsightsResponseItemsReceived = "itemsReceived";
inline constexpr StringLiteral AppInsightsResponseItemsAccepted = "itemsAccepted";
inline constexpr StringLiteral AppInsightsResponseErrors = "errors";
}
69 changes: 69 additions & 0 deletions include/vcpkg/base/curl.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#pragma once

#include <vcpkg/base/fwd/span.h>

#include <vcpkg/base/pragmas.h>

#include <vcpkg/commands.version.h>

VCPKG_MSVC_WARNING(push)
// note: disable warning triggered by curl headers
// ws2tcpip.h(968): warning C6101: Returning uninitialized memory '*Mtu': A successful path through the function does
// not set the named _Out_ parameter.
VCPKG_MSVC_WARNING(disable : 6101)
#include <curl/curl.h>
#include <curl/multi.h>
VCPKG_MSVC_WARNING(pop)

namespace vcpkg
{
CURLcode get_curl_global_init_status() noexcept;

struct CurlEasyHandle
{
CurlEasyHandle();
CurlEasyHandle(CurlEasyHandle&& other) noexcept;
CurlEasyHandle& operator=(CurlEasyHandle&& other) noexcept;
~CurlEasyHandle();

CURL* get();

private:
CURL* m_ptr = nullptr;
};

struct CurlMultiHandle
{
CurlMultiHandle();
CurlMultiHandle(CurlMultiHandle&& other) noexcept;
CurlMultiHandle& operator=(CurlMultiHandle&& other) noexcept;
~CurlMultiHandle();

// Adds an easy handle to the multi handle but doesn't take ownership of it.
// Makes sure that the easy handle is removed from the multi handle on cleanup.
void add_easy_handle(CurlEasyHandle& easy_handle);

CURLM* get();

private:
CURLM* m_ptr = nullptr;
std::vector<CURL*> m_easy_handles;
};

struct CurlHeaders
{
CurlHeaders();
CurlHeaders(View<std::string> headers);
CurlHeaders(CurlHeaders&& other) noexcept;
CurlHeaders& operator=(CurlHeaders&& other) noexcept;
~CurlHeaders();

curl_slist* get() const;

private:
curl_slist* m_headers = nullptr;
};

constexpr char vcpkg_curl_user_agent[] =
"vcpkg/" VCPKG_BASE_VERSION_AS_STRING "-" VCPKG_VERSION_AS_STRING " (curl)";
}
Loading
Loading