mirror of
https://github.com/nsnail/Ocelot.git
synced 2025-08-04 19:22:27 +08:00
#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:
@ -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);
|
||||
|
Reference in New Issue
Block a user