Merge branch 'release-3.0.2'

This commit is contained in:
Tom Gardham-Pallister 2018-02-05 18:34:54 +00:00
commit ec7b4ff8fa
5 changed files with 71 additions and 6 deletions

View File

@ -2,6 +2,9 @@
[![Build status](https://ci.appveyor.com/api/projects/status/r6sv51qx36sis1je?svg=true)](https://ci.appveyor.com/project/TomPallister/ocelot-fcfpb) [![Build status](https://ci.appveyor.com/api/projects/status/r6sv51qx36sis1je?svg=true)](https://ci.appveyor.com/project/TomPallister/ocelot-fcfpb)
[![Windows Build history](https://buildstats.info/appveyor/chart/TomPallister/ocelot-fcfpb?branch=develop&includeBuildsFromPullRequest=false)](https://ci.appveyor.com/project/TomPallister/ocelot-fcfpb/history?branch=develop)
[![Coverage Status](https://coveralls.io/repos/github/TomPallister/Ocelot/badge.svg?branch=develop)](https://coveralls.io/github/TomPallister/Ocelot?branch=develop) [![Coverage Status](https://coveralls.io/repos/github/TomPallister/Ocelot/badge.svg?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 Ocelot is a .NET Api Gateway. This project is aimed at people using .NET running

View File

@ -422,6 +422,8 @@ private void PublishPackages(ConvertableDirectoryPath packagesDir, ConvertableFi
Information("Pushing package " + codePackage); Information("Pushing package " + codePackage);
Information("Calling NuGetPush");
NuGetPush( NuGetPush(
codePackage, codePackage,
new NuGetPushSettings { new NuGetPushSettings {

View File

@ -55,7 +55,7 @@ namespace Ocelot.Responder
using (Stream stream = new MemoryStream(content)) 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); await stream.CopyToAsync(context.Response.Body);
} }

View File

@ -19,10 +19,6 @@
<DebugSymbols>True</DebugSymbols> <DebugSymbols>True</DebugSymbols>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<Compile Remove="Responder\HttpContextResponderTests.cs" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\src\Ocelot\Ocelot.csproj" /> <ProjectReference Include="..\..\src\Ocelot\Ocelot.csproj" />
</ItemGroup> </ItemGroup>

View 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);
}
}
}