Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions mcpp.toml
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ members = [
"tests/examples/cuda-curand",
"tests/examples/cuda-driver",
"tests/examples/curl",
"tests/examples/curl-http2",
"tests/examples/djgpp-platform",
"tests/examples/mcpp-platforms",
"tests/examples/doctest",
Expand Down
5 changes: 5 additions & 0 deletions pkgs/c/compat.curl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,11 @@ package = {
features = {
["default"] = { implies = { "staticlib" } },
["staticlib"] = { defines = { "CURL_STATICLIB" } },
["http2"] = {
implies = { "staticlib" },
defines = { "USE_NGHTTP2" },
deps = { ["compat.nghttp2"] = "1.71.0" },
},
},

cflags = {
Expand Down
6 changes: 3 additions & 3 deletions pkgs/c/compat.nghttp2.lua
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ package = {
["mcpp_generated/include/nghttp2/nghttp2.h"] = [==[
#pragma once
#if defined(_MSC_VER)
// Match the upstream CMake fallback for the legacy ssize_t API on MSVC.
# include <sys/types.h>
// Match the pointer-sized ssize_t used by Windows consumers such as curl.
# include <BaseTsd.h>
# ifndef BUILDING_NGHTTP2
# pragma push_macro("ssize_t")
# endif
# undef ssize_t
# define ssize_t int
# define ssize_t SSIZE_T
#endif
#include <nghttp2.h>
#if defined(_MSC_VER) && !defined(BUILDING_NGHTTP2)
Expand Down
9 changes: 9 additions & 0 deletions tests/examples/curl-http2/mcpp.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[package]
name = "curl-http2-tests"
version = "0.1.0"

[dependencies.compat]
curl = { version = "8.21.0", features = ["http2"] }

[indices]
compat = { path = "../../.." }
22 changes: 22 additions & 0 deletions tests/examples/curl-http2/tests/http2.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include <curl/curl.h>

#include <cstdio>

int main() {
if (curl_global_init(CURL_GLOBAL_DEFAULT) != CURLE_OK) return 1;

const auto* info = curl_version_info(CURLVERSION_NOW);
const bool http2 = info && (info->features & CURL_VERSION_HTTP2) != 0;
CURL* handle = curl_easy_init();
const bool configured = handle &&
curl_easy_setopt(handle, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_2TLS) == CURLE_OK;
if (handle) curl_easy_cleanup(handle);
curl_global_cleanup();

if (!http2 || !configured) {
std::fprintf(stderr, "libcurl HTTP/2 support is unavailable\n");
return 2;
}
std::puts("libcurl reports HTTP/2 and accepts CURL_HTTP_VERSION_2TLS");
return 0;
}
6 changes: 6 additions & 0 deletions tests/examples/curl/tests/transfer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ int main() {
return 3;
}

if ((info->features & CURL_VERSION_HTTP2) != 0) {
std::println("libcurl enabled HTTP/2 without the http2 feature");
curl_global_cleanup();
return 7;
}

bool haveHttps = false;
bool haveHttp = false;
for (const char* const* p = info->protocols; p != nullptr && *p != nullptr; ++p) {
Expand Down
Loading