File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -115,6 +115,7 @@ members = [
115115 " tests/examples/cuda-curand" ,
116116 " tests/examples/cuda-driver" ,
117117 " tests/examples/curl" ,
118+ " tests/examples/curl-http2" ,
118119 " tests/examples/djgpp-platform" ,
119120 " tests/examples/mcpp-platforms" ,
120121 " tests/examples/doctest" ,
Original file line number Diff line number Diff line change @@ -110,6 +110,11 @@ package = {
110110 features = {
111111 [" default" ] = { implies = { " staticlib" } },
112112 [" staticlib" ] = { defines = { " CURL_STATICLIB" } },
113+ [" http2" ] = {
114+ implies = { " staticlib" },
115+ defines = { " USE_NGHTTP2" },
116+ deps = { [" compat.nghttp2" ] = " 1.71.0" },
117+ },
113118 },
114119
115120 cflags = {
Original file line number Diff line number Diff line change @@ -33,13 +33,13 @@ package = {
3333 [" mcpp_generated/include/nghttp2/nghttp2.h" ] = [==[
3434#pragma once
3535#if defined(_MSC_VER)
36- // Match the upstream CMake fallback for the legacy ssize_t API on MSVC .
37- # include <sys/types .h>
36+ // Match the pointer-sized ssize_t used by Windows consumers such as curl .
37+ # include <BaseTsd .h>
3838# ifndef BUILDING_NGHTTP2
3939# pragma push_macro("ssize_t")
4040# endif
4141# undef ssize_t
42- # define ssize_t int
42+ # define ssize_t SSIZE_T
4343#endif
4444#include <nghttp2.h>
4545#if defined(_MSC_VER) && !defined(BUILDING_NGHTTP2)
Original file line number Diff line number Diff line change 1+ [package ]
2+ name = " curl-http2-tests"
3+ version = " 0.1.0"
4+
5+ [dependencies .compat ]
6+ curl = { version = " 8.21.0" , features = [" http2" ] }
7+
8+ [indices ]
9+ compat = { path = " ../../.." }
Original file line number Diff line number Diff line change 1+ #include < curl/curl.h>
2+
3+ #include < cstdio>
4+
5+ int main () {
6+ if (curl_global_init (CURL_GLOBAL_DEFAULT ) != CURLE_OK ) return 1 ;
7+
8+ const auto * info = curl_version_info (CURLVERSION_NOW );
9+ const bool http2 = info && (info->features & CURL_VERSION_HTTP2 ) != 0 ;
10+ CURL * handle = curl_easy_init ();
11+ const bool configured = handle &&
12+ curl_easy_setopt (handle, CURLOPT_HTTP_VERSION , CURL_HTTP_VERSION_2TLS ) == CURLE_OK ;
13+ if (handle) curl_easy_cleanup (handle);
14+ curl_global_cleanup ();
15+
16+ if (!http2 || !configured) {
17+ std::fprintf (stderr, " libcurl HTTP/2 support is unavailable\n " );
18+ return 2 ;
19+ }
20+ std::puts (" libcurl reports HTTP/2 and accepts CURL_HTTP_VERSION_2TLS" );
21+ return 0 ;
22+ }
Original file line number Diff line number Diff line change @@ -48,6 +48,12 @@ int main() {
4848 return 3 ;
4949 }
5050
51+ if ((info->features & CURL_VERSION_HTTP2 ) != 0 ) {
52+ std::println (" libcurl enabled HTTP/2 without the http2 feature" );
53+ curl_global_cleanup ();
54+ return 7 ;
55+ }
56+
5157 bool haveHttps = false ;
5258 bool haveHttp = false ;
5359 for (const char * const * p = info->protocols ; p != nullptr && *p != nullptr ; ++p) {
You can’t perform that action at this time.
0 commit comments