Skip to content

Commit 397d85a

Browse files
authored
Merge pull request #1177 from h3xOo/various_fixes
Add enforced HTTP/3
2 parents 12ac5f8 + 2a147f2 commit 397d85a

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

cpr/session.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -659,6 +659,11 @@ void Session::SetHttpVersion(const HttpVersion& version) {
659659
curl_easy_setopt(curl_->handle, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_3);
660660
break;
661661
#endif
662+
#if LIBCURL_VERSION_NUM >= 0x075701 // 7.87.1, but corresponds to 7.88.0 tag
663+
case HttpVersionCode::VERSION_3_0_ONLY:
664+
curl_easy_setopt(curl_->handle, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_3ONLY);
665+
break;
666+
#endif
662667

663668
default: // Should not happen
664669
throw std::invalid_argument("Invalid/Unknown HTTP version type.");

include/cpr/http_version.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,14 @@ enum class HttpVersionCode {
4646
* Requires prior knowledge that the server supports HTTP 3.0 since there is no gracefully downgrade.
4747
* Fallback to HTTP 1.1 if negotiation fails.
4848
**/
49-
VERSION_3_0
49+
VERSION_3_0,
50+
#endif
51+
#if LIBCURL_VERSION_NUM >= 0x075701 // 7.87.1, but corresponds to 7.88.0 tag
52+
/**
53+
* Enforce HTTP 3.0 requests without fallback.
54+
* Requires prior knowledge that the server supports HTTP 3.0 since there is no gracefully downgrade.
55+
**/
56+
VERSION_3_0_ONLY
5057
#endif
5158
};
5259

0 commit comments

Comments
 (0)