@@ -17,19 +17,19 @@ public static partial class ItExtensions
1717{
1818 private sealed class HttpHeadersMatcher
1919 {
20- private readonly List < KeyValuePair < string , HttpHeaderValue > > _requiredHeaders = [ ] ;
20+ private readonly List < ( string Name , HttpHeaderValue Value ) > _requiredHeaders = [ ] ;
2121
2222 public void AddRequiredHeader ( string name , HttpHeaderValue value )
23- => _requiredHeaders . Add ( new KeyValuePair < string , HttpHeaderValue > ( name , value ) ) ;
23+ => _requiredHeaders . Add ( ( name , value ) ) ;
2424
25- public void AddRequiredHeader ( IEnumerable < KeyValuePair < string , HttpHeaderValue > > headers )
25+ public void AddRequiredHeader ( IEnumerable < ( string Name , HttpHeaderValue Value ) > headers )
2626 => _requiredHeaders . AddRange ( headers ) ;
2727
2828 public void AddRequiredHeader ( string headers )
2929 => _requiredHeaders . AddRange ( ExtractHeaders ( headers ) ) ;
3030
3131 public bool Matches ( HttpHeaders messageHeaders )
32- => _requiredHeaders . All ( header => MatchesHeader ( header . Key , header . Value , messageHeaders ) ) ;
32+ => _requiredHeaders . All ( header => MatchesHeader ( header . Name , header . Value , messageHeaders ) ) ;
3333
3434 private static bool MatchesHeader ( string name , HttpHeaderValue value , HttpHeaders messageHeaders )
3535 {
@@ -41,9 +41,9 @@ private static bool MatchesHeader(string name, HttpHeaderValue value, HttpHeader
4141 return values . Any ( value . Matches ) ;
4242 }
4343
44- private static List < KeyValuePair < string , HttpHeaderValue > > ExtractHeaders ( string headers )
44+ private static List < ( string , HttpHeaderValue ) > ExtractHeaders ( string headers )
4545 {
46- List < KeyValuePair < string , HttpHeaderValue > > headerList = new ( ) ;
46+ List < ( string , HttpHeaderValue ) > headerList = new ( ) ;
4747 using StringReader reader = new ( headers ) ;
4848 string ? line = reader . ReadLine ( ) ;
4949 while ( ! string . IsNullOrWhiteSpace ( line ) )
@@ -55,7 +55,7 @@ private static List<KeyValuePair<string, HttpHeaderValue>> ExtractHeaders(string
5555 throw new ArgumentException ( "The header contained an invalid line: " + line , nameof ( headers ) ) ;
5656 }
5757
58- headerList . Add ( new KeyValuePair < string , HttpHeaderValue > ( parts [ 0 ] , parts [ 1 ] . TrimStart ( ' ' ) ) ) ;
58+ headerList . Add ( ( parts [ 0 ] . Trim ( ) , parts [ 1 ] . TrimStart ( ' ' ) ) ) ;
5959 line = reader . ReadLine ( ) ;
6060 }
6161
@@ -77,7 +77,7 @@ public interface IHttpHeaderParameter<out TParameter>
7777 /// <summary>
7878 /// Expects the <see cref="HttpContent" /> to contain the given <paramref name="headers" />.
7979 /// </summary>
80- TParameter WithHeaders ( IEnumerable < KeyValuePair < string , HttpHeaderValue > > headers ) ;
80+ TParameter WithHeaders ( params ( string Name , HttpHeaderValue Value ) [ ] headers ) ;
8181
8282 /// <summary>
8383 /// Expects the <see cref="HttpContent" /> to contain the given <paramref name="headers" />.
0 commit comments