@@ -22,7 +22,7 @@ public static class RestResponseExtensions {
22
22
/// <param name="headerName">Name of the header</param>
23
23
/// <returns>Header value or null if the header is not found in the response</returns>
24
24
public static string ? GetHeaderValue ( this RestResponse response , string headerName )
25
- => response . Headers ? . FirstOrDefault ( x => NameIs ( x . Name , headerName ) ) ? . Value ? . ToString ( ) ;
25
+ => response . Headers ? . FirstOrDefault ( x => NameIs ( x . Name , headerName ) ) ? . Value . ToString ( ) ;
26
26
27
27
/// <summary>
28
28
/// Gets all the values of the header with the specified name.
@@ -33,7 +33,29 @@ public static class RestResponseExtensions {
33
33
public static string [ ] GetHeaderValues ( this RestResponse response , string headerName )
34
34
=> response . Headers
35
35
? . Where ( x => NameIs ( x . Name , headerName ) )
36
- . Select ( x => x . Value ? . ToString ( ) ?? "" )
36
+ . Select ( x => x . Value . ToString ( ) ?? "" )
37
+ . ToArray ( ) ??
38
+ [ ] ;
39
+
40
+ /// <summary>
41
+ /// Gets the value of the content header with the specified name.
42
+ /// </summary>
43
+ /// <param name="response">Response object</param>
44
+ /// <param name="headerName">Name of the header</param>
45
+ /// <returns>Header value or null if the content header is not found in the response</returns>
46
+ public static string ? GetContentHeaderValue ( this RestResponse response , string headerName )
47
+ => response . ContentHeaders ? . FirstOrDefault ( x => NameIs ( x . Name , headerName ) ) ? . Value . ToString ( ) ;
48
+
49
+ /// <summary>
50
+ /// Gets all the values of the content header with the specified name.
51
+ /// </summary>
52
+ /// <param name="response">Response object</param>
53
+ /// <param name="headerName">Name of the header</param>
54
+ /// <returns>Array of header values or empty array if the content header is not found in the response</returns>
55
+ public static string [ ] GetContentHeaderValues ( this RestResponse response , string headerName )
56
+ => response . ContentHeaders
57
+ ? . Where ( x => NameIs ( x . Name , headerName ) )
58
+ . Select ( x => x . Value . ToString ( ) ?? "" )
37
59
. ToArray ( ) ??
38
60
[ ] ;
39
61
0 commit comments