From 9885a41f091c4f24df451ee1b9556751fcb6bd56 Mon Sep 17 00:00:00 2001 From: Alexey Zimarev Date: Mon, 27 May 2024 12:12:53 +0200 Subject: [PATCH] Add Version --- src/RestSharp/Request/RestRequest.cs | 5 +++++ src/RestSharp/RestClient.Async.cs | 1 + 2 files changed, 6 insertions(+) diff --git a/src/RestSharp/Request/RestRequest.cs b/src/RestSharp/Request/RestRequest.cs index 40b8e074c..90854652f 100644 --- a/src/RestSharp/Request/RestRequest.cs +++ b/src/RestSharp/Request/RestRequest.cs @@ -166,6 +166,11 @@ public RestRequest(Uri resource, Method method = Method.Get) /// Can be used to skip container or root elements that do not have corresponding deserialization targets. /// public string? RootElement { get; set; } + + /// + /// HTTP version for the request. Default is Version11. + /// + public Version Version { get; set; } = HttpVersion.Version11; /// /// When supplied, the function will be called before calling the deserializer diff --git a/src/RestSharp/RestClient.Async.cs b/src/RestSharp/RestClient.Async.cs index 55e02c70c..ce6706216 100644 --- a/src/RestSharp/RestClient.Async.cs +++ b/src/RestSharp/RestClient.Async.cs @@ -113,6 +113,7 @@ async Task ExecuteRequestAsync(RestRequest request, CancellationTo message.Content = requestContent.BuildContent(); message.Headers.Host = Options.BaseHost; message.Headers.CacheControl = request.CachePolicy ?? Options.CachePolicy; + message.Version = request.Version; using var timeoutCts = new CancellationTokenSource(request.Timeout ?? Options.Timeout ?? _defaultTimeout); using var cts = CancellationTokenSource.CreateLinkedTokenSource(timeoutCts.Token, cancellationToken);