#263 map all content specific headers to downstream request content property, make sure we dont map them to request specific headers, added a gzip encoding acceptance test (#267)

This commit is contained in:
Tom Pallister
2018-03-08 07:32:06 +00:00
committed by GitHub
parent db05935b89
commit 5e9ee1f2ed
4 changed files with 286 additions and 14 deletions

View File

@ -22,6 +22,8 @@ using Ocelot.Middleware;
using Shouldly;
using ConfigurationBuilder = Microsoft.Extensions.Configuration.ConfigurationBuilder;
using Ocelot.AcceptanceTests.Caching;
using System.IO.Compression;
using System.Text;
namespace Ocelot.AcceptanceTests
{
@ -582,6 +584,22 @@ namespace Ocelot.AcceptanceTests
_postContent = new StringContent(postcontent);
}
public void GivenThePostHasGzipContent(object input)
{
string json = JsonConvert.SerializeObject(input);
byte[] jsonBytes = Encoding.UTF8.GetBytes(json);
MemoryStream ms = new MemoryStream();
using (GZipStream gzip = new GZipStream(ms, CompressionMode.Compress, true))
{
gzip.Write(jsonBytes, 0, jsonBytes.Length);
}
ms.Position = 0;
StreamContent content = new StreamContent(ms);
content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
content.Headers.ContentEncoding.Add("gzip");
_postContent = content;
}
public void ThenTheResponseBodyShouldBe(string expectedBody)
{
_response.Content.ReadAsStringAsync().Result.ShouldBe(expectedBody);