Skip to content

Commit

Permalink
Set Version to generic RestResponse (#2199)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
biasso authored May 22, 2024
1 parent 20e1115 commit 453260c
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions src/RestSharp/Response/RestResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,22 +35,23 @@ public class RestResponse<T>(RestRequest request) : RestResponse(request) {
public static RestResponse<T> FromResponse(RestResponse response)
=> new(response.Request) {
Content = response.Content,
RawBytes = response.RawBytes,
ContentEncoding = response.ContentEncoding,
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
};
}

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

return new RestResponse(request) {
Content = content,
RawBytes = bytes,
ContentEncoding = httpResponse.Content?.Headers.ContentEncoding ?? Array.Empty<string>(),
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
};
}
}
Expand Down

0 comments on commit 453260c

Please sign in to comment.