mirror of
https://github.com/nsnail/Ocelot.git
synced 2025-04-23 00:32:50 +08:00
Merge branch 'release-3.0.2'
This commit is contained in:
commit
ec7b4ff8fa
@ -2,6 +2,9 @@
|
||||
|
||||
[](https://ci.appveyor.com/project/TomPallister/ocelot-fcfpb)
|
||||
|
||||
[](https://ci.appveyor.com/project/TomPallister/ocelot-fcfpb/history?branch=develop)
|
||||
|
||||
|
||||
[](https://coveralls.io/github/TomPallister/Ocelot?branch=develop)
|
||||
|
||||
Ocelot is a .NET Api Gateway. This project is aimed at people using .NET running
|
||||
|
@ -422,6 +422,8 @@ private void PublishPackages(ConvertableDirectoryPath packagesDir, ConvertableFi
|
||||
|
||||
Information("Pushing package " + codePackage);
|
||||
|
||||
Information("Calling NuGetPush");
|
||||
|
||||
NuGetPush(
|
||||
codePackage,
|
||||
new NuGetPushSettings {
|
||||
|
@ -55,7 +55,7 @@ namespace Ocelot.Responder
|
||||
|
||||
using (Stream stream = new MemoryStream(content))
|
||||
{
|
||||
if (response.StatusCode != HttpStatusCode.NotModified)
|
||||
if (response.StatusCode != HttpStatusCode.NotModified && context.Response.ContentLength != 0)
|
||||
{
|
||||
await stream.CopyToAsync(context.Response.Body);
|
||||
}
|
||||
|
@ -19,10 +19,6 @@
|
||||
<DebugSymbols>True</DebugSymbols>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Remove="Responder\HttpContextResponderTests.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\Ocelot\Ocelot.csproj" />
|
||||
</ItemGroup>
|
||||
|
64
test/Ocelot.UnitTests/Responder/HttpContextResponderTests.cs
Normal file
64
test/Ocelot.UnitTests/Responder/HttpContextResponderTests.cs
Normal file
@ -0,0 +1,64 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Ocelot.Headers;
|
||||
using Ocelot.Responder;
|
||||
using Shouldly;
|
||||
using Xunit;
|
||||
|
||||
namespace Ocelot.UnitTests.Responder
|
||||
{
|
||||
public class HttpContextResponderTests
|
||||
{
|
||||
private readonly HttpContextResponder _responder;
|
||||
private RemoveOutputHeaders _removeOutputHeaders;
|
||||
|
||||
public HttpContextResponderTests()
|
||||
{
|
||||
_removeOutputHeaders = new RemoveOutputHeaders();
|
||||
_responder = new HttpContextResponder(_removeOutputHeaders);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
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 header = httpContext.Response.Headers["Transfer-Encoding"];
|
||||
header.ShouldBeEmpty();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
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 header = httpContext.Response.Headers["Content-Length"];
|
||||
header.First().ShouldBe("4");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
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 header = httpContext.Response.Headers["test"];
|
||||
header.First().ShouldBe("test");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void should_call_without_exception()
|
||||
{
|
||||
var httpContext = new DefaultHttpContext();
|
||||
_responder.SetErrorResponseOnContext(httpContext, 500);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user