mirror of
https://github.com/nsnail/Ocelot.git
synced 2025-06-19 11:18:16 +08:00
* #298 initial hacking around better aggregation * #298 bit more hacking around * #298 abstraction over httpresponsemessage * #298 tidying up * #298 docs * #298 missed this
This commit is contained in:
@ -1,10 +1,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Ocelot.Headers;
|
||||
using Ocelot.Middleware;
|
||||
using Ocelot.Middleware.Multiplexer;
|
||||
using Ocelot.Responder;
|
||||
using Shouldly;
|
||||
using Xunit;
|
||||
@ -26,9 +27,13 @@ namespace Ocelot.UnitTests.Responder
|
||||
public void should_remove_transfer_encoding_header()
|
||||
{
|
||||
var httpContext = new DefaultHttpContext();
|
||||
var httpResponseMessage = new HttpResponseMessage {Content = new StringContent("")};
|
||||
httpResponseMessage.Headers.Add("Transfer-Encoding", "woop");
|
||||
_responder.SetResponseOnHttpContext(httpContext, httpResponseMessage).GetAwaiter().GetResult();
|
||||
var response = new DownstreamResponse(new StringContent(""), HttpStatusCode.OK,
|
||||
new List<KeyValuePair<string, IEnumerable<string>>>
|
||||
{
|
||||
new KeyValuePair<string, IEnumerable<string>>("Transfer-Encoding", new List<string> {"woop"})
|
||||
});
|
||||
|
||||
_responder.SetResponseOnHttpContext(httpContext, response).GetAwaiter().GetResult();
|
||||
var header = httpContext.Response.Headers["Transfer-Encoding"];
|
||||
header.ShouldBeEmpty();
|
||||
}
|
||||
@ -37,8 +42,10 @@ namespace Ocelot.UnitTests.Responder
|
||||
public void should_have_content_length()
|
||||
{
|
||||
var httpContext = new DefaultHttpContext();
|
||||
var httpResponseMessage = new HttpResponseMessage { Content = new StringContent("test") };
|
||||
_responder.SetResponseOnHttpContext(httpContext, httpResponseMessage).GetAwaiter().GetResult();
|
||||
var response = new DownstreamResponse(new StringContent("test"), HttpStatusCode.OK,
|
||||
new List<KeyValuePair<string, IEnumerable<string>>>());
|
||||
|
||||
_responder.SetResponseOnHttpContext(httpContext, response).GetAwaiter().GetResult();
|
||||
var header = httpContext.Response.Headers["Content-Length"];
|
||||
header.First().ShouldBe("4");
|
||||
}
|
||||
@ -47,9 +54,13 @@ namespace Ocelot.UnitTests.Responder
|
||||
public void should_add_header()
|
||||
{
|
||||
var httpContext = new DefaultHttpContext();
|
||||
var httpResponseMessage = new HttpResponseMessage { Content = new StringContent("test") };
|
||||
httpResponseMessage.Headers.Add("test", "test");
|
||||
_responder.SetResponseOnHttpContext(httpContext, httpResponseMessage).GetAwaiter().GetResult();
|
||||
var response = new DownstreamResponse(new StringContent(""), HttpStatusCode.OK,
|
||||
new List<KeyValuePair<string, IEnumerable<string>>>
|
||||
{
|
||||
new KeyValuePair<string, IEnumerable<string>>("test", new List<string> {"test"})
|
||||
});
|
||||
|
||||
_responder.SetResponseOnHttpContext(httpContext, response).GetAwaiter().GetResult();
|
||||
var header = httpContext.Response.Headers["test"];
|
||||
header.First().ShouldBe("test");
|
||||
}
|
||||
|
Reference in New Issue
Block a user