aliostad/CacheCow — pull request #79 by drzoidb3rg (2014-08-15 10:32:26+00:00)
Title: fix vary by param issue

I found an issue using the Accept header, it did not cache my responses

For CacheCow.Client.Tests.IntegrationTests.Test_GoogleImage

add adding httpClient.DefaultRequestHeaders.Add("Accept", "image/png");

breaks the test

this is because the following function

public bool TryGetValue(string uri, out IEnumerable headers)
{
headers = (string[])_cache.Get(uri);
return headers!=null;
}

assumes that headers is either a full array or null. In the scenario when subsequent requests are made with an Accepts header, the
variable 'headers' was found to be null for the 1st request, and and empty string array for the 2nd request.
Solution was to check for 'is null or empty array'
so :
return headers!=null;
changed to :
return (!(headers == null || headers.ToArray().Length == 0));