mirror of
https://github.com/nsnail/Ocelot.git
synced 2025-04-22 06:22:50 +08:00
#603 return 502 when request cannot be completed
This commit is contained in:
parent
f15e3a9acf
commit
f35a07a3da
@ -42,7 +42,7 @@ namespace Ocelot.Responder
|
|||||||
|
|
||||||
if (errors.Any(e => e.Code == OcelotErrorCode.UnableToCompleteRequestError))
|
if (errors.Any(e => e.Code == OcelotErrorCode.UnableToCompleteRequestError))
|
||||||
{
|
{
|
||||||
return 500;
|
return 502;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 404;
|
return 404;
|
||||||
|
@ -18,6 +18,38 @@
|
|||||||
_steps = new Steps();
|
_steps = new Steps();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void should_return_bad_gateway_error_if_downstream_service_doesnt_respond()
|
||||||
|
{
|
||||||
|
var configuration = new FileConfiguration
|
||||||
|
{
|
||||||
|
ReRoutes = new List<FileReRoute>
|
||||||
|
{
|
||||||
|
new FileReRoute
|
||||||
|
{
|
||||||
|
DownstreamPathTemplate = "/",
|
||||||
|
UpstreamPathTemplate = "/",
|
||||||
|
UpstreamHttpMethod = new List<string> { "Get" },
|
||||||
|
DownstreamHostAndPorts = new List<FileHostAndPort>
|
||||||
|
{
|
||||||
|
new FileHostAndPort
|
||||||
|
{
|
||||||
|
Host = "localhost",
|
||||||
|
Port = 53876,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
DownstreamScheme = "http",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
this.Given(x => _steps.GivenThereIsAConfiguration(configuration))
|
||||||
|
.And(x => _steps.GivenOcelotIsRunning())
|
||||||
|
.When(x => _steps.WhenIGetUrlOnTheApiGateway("/"))
|
||||||
|
.Then(x => _steps.ThenTheStatusCodeShouldBe(HttpStatusCode.BadGateway))
|
||||||
|
.BDDfy();
|
||||||
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void should_return_internal_server_error_if_downstream_service_returns_internal_server_error()
|
public void should_return_internal_server_error_if_downstream_service_returns_internal_server_error()
|
||||||
{
|
{
|
||||||
|
@ -89,7 +89,7 @@ namespace Ocelot.AcceptanceTests
|
|||||||
.And(x => _steps.GivenThereIsAConfiguration(configuration))
|
.And(x => _steps.GivenThereIsAConfiguration(configuration))
|
||||||
.And(x => _steps.GivenOcelotIsRunning())
|
.And(x => _steps.GivenOcelotIsRunning())
|
||||||
.When(x => _steps.WhenIGetUrlOnTheApiGateway("/"))
|
.When(x => _steps.WhenIGetUrlOnTheApiGateway("/"))
|
||||||
.Then(x => _steps.ThenTheStatusCodeShouldBe(HttpStatusCode.InternalServerError))
|
.Then(x => _steps.ThenTheStatusCodeShouldBe(HttpStatusCode.BadGateway))
|
||||||
.BDDfy();
|
.BDDfy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,9 +47,9 @@ namespace Ocelot.UnitTests.Responder
|
|||||||
|
|
||||||
[Theory]
|
[Theory]
|
||||||
[InlineData(OcelotErrorCode.UnableToCompleteRequestError)]
|
[InlineData(OcelotErrorCode.UnableToCompleteRequestError)]
|
||||||
public void should_return_internal_server_error(OcelotErrorCode errorCode)
|
public void should_return_bad_gateway_error(OcelotErrorCode errorCode)
|
||||||
{
|
{
|
||||||
ShouldMapErrorToStatusCode(errorCode, HttpStatusCode.InternalServerError);
|
ShouldMapErrorToStatusCode(errorCode, HttpStatusCode.BadGateway);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Theory]
|
[Theory]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user