18
18
using System . Text ;
19
19
using RestSharp . Extensions ;
20
20
21
+ // ReSharper disable SuggestBaseTypeForParameter
22
+
21
23
namespace RestSharp ;
22
24
23
25
/// <summary>
@@ -42,6 +44,7 @@ public static RestResponse<T> FromResponse(RestResponse response)
42
44
ErrorMessage = response . ErrorMessage ,
43
45
ErrorException = response . ErrorException ,
44
46
Headers = response . Headers ,
47
+ ContentHeaders = response . ContentHeaders ,
45
48
IsSuccessful = response . IsSuccessful ,
46
49
ResponseStatus = response . ResponseStatus ,
47
50
ResponseUri = response . ResponseUri ,
@@ -57,13 +60,9 @@ public static RestResponse<T> FromResponse(RestResponse response)
57
60
/// </summary>
58
61
[ DebuggerDisplay ( "{" + nameof ( DebuggerDisplay ) + "()}" ) ]
59
62
public class RestResponse : RestResponseBase {
60
- RestResponse SetHeaders ( HttpResponseHeaders headers ) {
61
- var headerParams = headers
62
- . SelectMany ( x => x . Value . Select ( y => ( x . Key , y ) ) )
63
- . Select ( x => new HeaderParameter ( x . Key , x . y ) )
64
- . ToList ( ) ;
65
- return this . With ( x => x . Headers = headerParams ) ;
66
- }
63
+ RestResponse SetHeaders ( HttpResponseHeaders httpHeaders ) => this . With ( x => x . Headers = httpHeaders . GetHeaderParameters ( ) ) ;
64
+
65
+ RestResponse SetContentHeaders ( HttpContentHeaders httpHeaders ) => this . With ( x => x . ContentHeaders = httpHeaders . GetHeaderParameters ( ) ) ;
67
66
68
67
RestResponse SetCookies ( CookieCollection cookies ) => this . With ( x => x . Cookies = cookies ) ;
69
68
@@ -124,6 +123,7 @@ async Task<RestResponse> GetDefaultResponse() {
124
123
Request = request
125
124
}
126
125
. SetHeaders ( httpResponse . Headers )
126
+ . SetContentHeaders ( httpResponse . Content . Headers )
127
127
. SetCookies ( cookieCollection ) ;
128
128
}
129
129
}
0 commit comments