From ad6791c9b96c793239bd999fbf44efb1c2ff07cc Mon Sep 17 00:00:00 2001 From: Simone Biassoni Date: Sat, 18 May 2024 10:03:10 +0200 Subject: [PATCH 1/2] Set Version to generic RestResponse Fix #2196 --- src/RestSharp/Response/RestResponse.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/RestSharp/Response/RestResponse.cs b/src/RestSharp/Response/RestResponse.cs index 68290b28d..eab8939c9 100644 --- a/src/RestSharp/Response/RestResponse.cs +++ b/src/RestSharp/Response/RestResponse.cs @@ -37,6 +37,7 @@ public static RestResponse FromResponse(RestResponse response) Content = response.Content, RawBytes = response.RawBytes, ContentEncoding = response.ContentEncoding, + Version = response.Version, ContentLength = response.ContentLength, ContentType = response.ContentType, Cookies = response.Cookies, From e0dc8e323cc7d5e1e429684f50cdb9f82f7bed3e Mon Sep 17 00:00:00 2001 From: Simone Biassoni Date: Sat, 18 May 2024 10:08:55 +0200 Subject: [PATCH 2/2] Alphabetically sort initialized properties of RestResponse Sorting the properties alphabetically to improve code readability and makes it easier to locate specific properties during maintenance. --- src/RestSharp/Response/RestResponse.cs | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/RestSharp/Response/RestResponse.cs b/src/RestSharp/Response/RestResponse.cs index eab8939c9..7aba25740 100644 --- a/src/RestSharp/Response/RestResponse.cs +++ b/src/RestSharp/Response/RestResponse.cs @@ -35,23 +35,23 @@ public class RestResponse(RestRequest request) : RestResponse(request) { public static RestResponse FromResponse(RestResponse response) => new(response.Request) { Content = response.Content, - RawBytes = response.RawBytes, ContentEncoding = response.ContentEncoding, - Version = response.Version, + ContentHeaders = response.ContentHeaders, ContentLength = response.ContentLength, ContentType = response.ContentType, Cookies = response.Cookies, - ErrorMessage = response.ErrorMessage, ErrorException = response.ErrorException, + ErrorMessage = response.ErrorMessage, Headers = response.Headers, - ContentHeaders = response.ContentHeaders, IsSuccessStatusCode = response.IsSuccessStatusCode, + RawBytes = response.RawBytes, ResponseStatus = response.ResponseStatus, ResponseUri = response.ResponseUri, + RootElement = response.RootElement, Server = response.Server, StatusCode = response.StatusCode, StatusDescription = response.StatusDescription, - RootElement = response.RootElement + Version = response.Version }; } @@ -82,22 +82,22 @@ async Task GetDefaultResponse() { return new RestResponse(request) { Content = content, - RawBytes = bytes, ContentEncoding = httpResponse.Content?.Headers.ContentEncoding ?? Array.Empty(), - Version = httpResponse.RequestMessage?.Version, + ContentHeaders = httpResponse.Content?.Headers.GetHeaderParameters(), ContentLength = httpResponse.Content?.Headers.ContentLength, ContentType = httpResponse.Content?.Headers.ContentType?.MediaType, - ResponseStatus = calculateResponseStatus(httpResponse), + Cookies = cookieCollection, ErrorException = httpResponse.MaybeException(), + Headers = httpResponse.Headers.GetHeaderParameters(), + IsSuccessStatusCode = httpResponse.IsSuccessStatusCode, + RawBytes = bytes, + ResponseStatus = calculateResponseStatus(httpResponse), ResponseUri = httpResponse.RequestMessage?.RequestUri, + RootElement = request.RootElement, Server = httpResponse.Headers.Server.ToString(), StatusCode = httpResponse.StatusCode, StatusDescription = httpResponse.ReasonPhrase, - IsSuccessStatusCode = httpResponse.IsSuccessStatusCode, - Headers = httpResponse.Headers.GetHeaderParameters(), - ContentHeaders = httpResponse.Content?.Headers.GetHeaderParameters(), - Cookies = cookieCollection, - RootElement = request.RootElement + Version = httpResponse.RequestMessage?.Version }; } }