File tree Expand file tree Collapse file tree 2 files changed +8
-12
lines changed
HttpClient.Caching/InMemory
Tests/HttpClient.Caching.Tests/InMemory Expand file tree Collapse file tree 2 files changed +8
-12
lines changed Original file line number Diff line number Diff line change @@ -51,13 +51,9 @@ public string GetKey(HttpRequestMessage request)
5151 {
5252 sb . AppendFormat ( "HEA_{0}_{1};" , headerName , this . GetHeaderValue ( request , headerName ) ) ;
5353 }
54- else
55- {
56- sb . Append ( "HEA_;" ) ;
57- }
58-
5954 }
6055 }
56+
6157 sb . AppendFormat ( "URI_{0};" , request . RequestUri ) ;
6258
6359 return sb . ToString ( ) ;
@@ -75,15 +71,15 @@ private string GetHeaderValue(HttpRequestMessage request, string headerName)
7571 throw new ArgumentException ( $ "'{ nameof ( headerName ) } ' cannot be null or empty.", nameof ( headerName ) ) ;
7672 }
7773
78- var retVal = string . Empty ;
74+ var orderedHeaderValues = string . Empty ;
7975
8076 var headerValues = request . Headers . GetValues ( headerName ) ;
8177 if ( headerValues != null )
8278 {
83- retVal = string . Join ( "," , headerValues . OrderBy ( i => i ) ) ;
79+ orderedHeaderValues = string . Join ( "," , headerValues . OrderBy ( i => i ) ) ;
8480 }
8581
86- return retVal ;
82+ return orderedHeaderValues ;
8783 }
8884 }
8985}
Original file line number Diff line number Diff line change @@ -34,7 +34,7 @@ public void ShouldGetKey_EmptyHeaderNames()
3434 public void ShouldGetKey_WithMatchingHeader ( )
3535 {
3636 // Arrange
37- var headersNames = new [ ] { "X-HEADER-1 " , "X-HEADER-2 " } ;
37+ var headersNames = new [ ] { "X-HEADER-2 " , "X-HEADER-1 " } ;
3838 var cacheKeysProvider = new MethodUriHeadersCacheKeysProvider ( headersNames ) ;
3939 var request = new HttpRequestMessage
4040 {
@@ -47,14 +47,14 @@ public void ShouldGetKey_WithMatchingHeader()
4747 var cacheKey = cacheKeysProvider . GetKey ( request ) ;
4848
4949 // Assert
50- cacheKey . Should ( ) . Be ( "MET_GET;HEA_X-HEADER-1_Value1;HEA_; URI_http://unittest/;" ) ;
50+ cacheKey . Should ( ) . Be ( "MET_GET;HEA_X-HEADER-1_Value1;URI_http://unittest/;" ) ;
5151 }
5252
5353 [ Fact ]
5454 public void ShouldGetKey_WithoutMatchingHeader ( )
5555 {
5656 // Arrange
57- var headersNames = new [ ] { "X-HEADER-1 " , "X-HEADER-2 " } ;
57+ var headersNames = new [ ] { "X-HEADER-2 " , "X-HEADER-1 " } ;
5858 var cacheKeysProvider = new MethodUriHeadersCacheKeysProvider ( headersNames ) ;
5959 var request = new HttpRequestMessage
6060 {
@@ -67,7 +67,7 @@ public void ShouldGetKey_WithoutMatchingHeader()
6767 var cacheKey = cacheKeysProvider . GetKey ( request ) ;
6868
6969 // Assert
70- cacheKey . Should ( ) . Be ( "MET_GET;HEA_;HEA_; URI_http://unittest/;" ) ;
70+ cacheKey . Should ( ) . Be ( "MET_GET;URI_http://unittest/;" ) ;
7171 }
7272 }
7373}
You can’t perform that action at this time.
0 commit comments