Skip to content

Commit

Permalink
integration test cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
tippmar-nr committed Nov 8, 2023
1 parent 3429f82 commit a5da07f
Showing 1 changed file with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,21 @@ public string Get(string endpoint)
var resultBytes = response.Content.ReadAsByteArrayAsync().Result;
Assert.NotNull(resultBytes);

using (var ms = new MemoryStream(resultBytes))
using (var gzip = new GZipStream(ms, CompressionMode.Decompress))
if (response.Content.Headers.ContentEncoding != null &&
response.Content.Headers.ContentEncoding.ToString() == "gzip")
{
var reader = new StreamReader(gzip, Encoding.UTF8);
using (var ms = new MemoryStream(resultBytes))
using (var gzip = new GZipStream(ms, CompressionMode.Decompress))
{
var reader = new StreamReader(gzip, Encoding.UTF8);

var result = reader.ReadToEndAsync().Result;
Assert.NotNull(result);
return result;
var result = reader.ReadToEndAsync().Result;
Assert.NotNull(result);
return result;
}
}
else // not compressed
return response.Content.ReadAsStringAsync().Result;
}
}
}
Expand Down

0 comments on commit a5da07f

Please sign in to comment.