@@ -22,7 +22,7 @@ public static class RestResponseExtensions {
2222 /// <param name="headerName">Name of the header</param>
2323 /// <returns>Header value or null if the header is not found in the response</returns>
2424 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 ( ) ;
2626
2727 /// <summary>
2828 /// Gets all the values of the header with the specified name.
@@ -33,7 +33,29 @@ public static class RestResponseExtensions {
3333 public static string [ ] GetHeaderValues ( this RestResponse response , string headerName )
3434 => response . Headers
3535 ? . 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 ( ) ?? "" )
3759 . ToArray ( ) ??
3860 [ ] ;
3961
0 commit comments