Skip to content

Commit 2a147f2

Browse files
committed
Add enforced HTTP/3 version
1 parent 4c41606 commit 2a147f2

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
@@ -618,6 +618,11 @@ void Session::SetHttpVersion(const HttpVersion& version) {
618618
curl_easy_setopt(curl_->handle, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_3);
619619
break;
620620
#endif
621+
#if LIBCURL_VERSION_NUM >= 0x075701 // 7.87.1, but corresponds to 7.88.0 tag
622+
case HttpVersionCode::VERSION_3_0_ONLY:
623+
curl_easy_setopt(curl_->handle, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_3ONLY);
624+
break;
625+
#endif
621626

622627
default: // Should not happen
623628
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)