Skip to content

Commit 453260c

Browse files
authored
Set Version to generic RestResponse (#2199)
* Set Version to generic RestResponse Fix #2196 * Alphabetically sort initialized properties of RestResponse Sorting the properties alphabetically to improve code readability and makes it easier to locate specific properties during maintenance.
1 parent 20e1115 commit 453260c

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

src/RestSharp/Response/RestResponse.cs

+13-12
Original file line numberDiff line numberDiff line change
@@ -35,22 +35,23 @@ public class RestResponse<T>(RestRequest request) : RestResponse(request) {
3535
public static RestResponse<T> FromResponse(RestResponse response)
3636
=> new(response.Request) {
3737
Content = response.Content,
38-
RawBytes = response.RawBytes,
3938
ContentEncoding = response.ContentEncoding,
39+
ContentHeaders = response.ContentHeaders,
4040
ContentLength = response.ContentLength,
4141
ContentType = response.ContentType,
4242
Cookies = response.Cookies,
43-
ErrorMessage = response.ErrorMessage,
4443
ErrorException = response.ErrorException,
44+
ErrorMessage = response.ErrorMessage,
4545
Headers = response.Headers,
46-
ContentHeaders = response.ContentHeaders,
4746
IsSuccessStatusCode = response.IsSuccessStatusCode,
47+
RawBytes = response.RawBytes,
4848
ResponseStatus = response.ResponseStatus,
4949
ResponseUri = response.ResponseUri,
50+
RootElement = response.RootElement,
5051
Server = response.Server,
5152
StatusCode = response.StatusCode,
5253
StatusDescription = response.StatusDescription,
53-
RootElement = response.RootElement
54+
Version = response.Version
5455
};
5556
}
5657

@@ -81,22 +82,22 @@ async Task<RestResponse> GetDefaultResponse() {
8182

8283
return new RestResponse(request) {
8384
Content = content,
84-
RawBytes = bytes,
8585
ContentEncoding = httpResponse.Content?.Headers.ContentEncoding ?? Array.Empty<string>(),
86-
Version = httpResponse.RequestMessage?.Version,
86+
ContentHeaders = httpResponse.Content?.Headers.GetHeaderParameters(),
8787
ContentLength = httpResponse.Content?.Headers.ContentLength,
8888
ContentType = httpResponse.Content?.Headers.ContentType?.MediaType,
89-
ResponseStatus = calculateResponseStatus(httpResponse),
89+
Cookies = cookieCollection,
9090
ErrorException = httpResponse.MaybeException(),
91+
Headers = httpResponse.Headers.GetHeaderParameters(),
92+
IsSuccessStatusCode = httpResponse.IsSuccessStatusCode,
93+
RawBytes = bytes,
94+
ResponseStatus = calculateResponseStatus(httpResponse),
9195
ResponseUri = httpResponse.RequestMessage?.RequestUri,
96+
RootElement = request.RootElement,
9297
Server = httpResponse.Headers.Server.ToString(),
9398
StatusCode = httpResponse.StatusCode,
9499
StatusDescription = httpResponse.ReasonPhrase,
95-
IsSuccessStatusCode = httpResponse.IsSuccessStatusCode,
96-
Headers = httpResponse.Headers.GetHeaderParameters(),
97-
ContentHeaders = httpResponse.Content?.Headers.GetHeaderParameters(),
98-
Cookies = cookieCollection,
99-
RootElement = request.RootElement
100+
Version = httpResponse.RequestMessage?.Version
100101
};
101102
}
102103
}

0 commit comments

Comments
 (0)