mirror of
https://github.com/nsnail/Ocelot.git
synced 2025-04-22 06:22:50 +08:00
parent
5e91d30352
commit
7dbfc46e7b
@ -52,9 +52,17 @@ namespace Ocelot.DownstreamUrlCreator.Middleware
|
|||||||
if(ContainsQueryString(dsPath))
|
if(ContainsQueryString(dsPath))
|
||||||
{
|
{
|
||||||
context.DownstreamRequest.AbsolutePath = GetPath(dsPath);
|
context.DownstreamRequest.AbsolutePath = GetPath(dsPath);
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(context.DownstreamRequest.Query))
|
||||||
|
{
|
||||||
context.DownstreamRequest.Query = GetQueryString(dsPath);
|
context.DownstreamRequest.Query = GetQueryString(dsPath);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
context.DownstreamRequest.Query += GetQueryString(dsPath).Replace('?', '&');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
RemoveQueryStringParametersThatHaveBeenUsedInTemplate(context);
|
RemoveQueryStringParametersThatHaveBeenUsedInTemplate(context);
|
||||||
|
|
||||||
|
@ -289,6 +289,39 @@
|
|||||||
.BDDfy();
|
.BDDfy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void issue_473_should_not_remove_additional_query_string()
|
||||||
|
{
|
||||||
|
var downstreamReRoute = new DownstreamReRouteBuilder()
|
||||||
|
.WithDownstreamPathTemplate("/Authorized/{action}?server={server}")
|
||||||
|
.WithUpstreamHttpMethod(new List<string> { "Post", "Get" })
|
||||||
|
.WithDownstreamScheme("http")
|
||||||
|
.WithUpstreamPathTemplate("/uc/Authorized/{server}/{action}")
|
||||||
|
.Build();
|
||||||
|
|
||||||
|
var config = new ServiceProviderConfigurationBuilder()
|
||||||
|
.Build();
|
||||||
|
|
||||||
|
this.Given(x => x.GivenTheDownStreamRouteIs(
|
||||||
|
new DownstreamRoute(
|
||||||
|
new List<PlaceholderNameAndValue>
|
||||||
|
{
|
||||||
|
new PlaceholderNameAndValue("{action}", "1"),
|
||||||
|
new PlaceholderNameAndValue("{server}", "2")
|
||||||
|
},
|
||||||
|
new ReRouteBuilder()
|
||||||
|
.WithDownstreamReRoute(downstreamReRoute)
|
||||||
|
.WithUpstreamHttpMethod(new List<string> { "Post", "Get" })
|
||||||
|
.Build())))
|
||||||
|
.And(x => x.GivenTheDownstreamRequestUriIs("http://localhost:5000/uc/Authorized/2/1/refresh?refreshToken=2288356cfb1338fdc5ff4ca558ec785118dfe1ff2864340937da8226863ff66d"))
|
||||||
|
.And(x => GivenTheServiceProviderConfigIs(config))
|
||||||
|
.And(x => x.GivenTheUrlReplacerWillReturn("/Authorized/1?server=2"))
|
||||||
|
.When(x => x.WhenICallTheMiddleware())
|
||||||
|
.Then(x => x.ThenTheDownstreamRequestUriIs("http://localhost:5000/Authorized/1?refreshToken=2288356cfb1338fdc5ff4ca558ec785118dfe1ff2864340937da8226863ff66d&server=2"))
|
||||||
|
.And(x => ThenTheQueryStringIs("?refreshToken=2288356cfb1338fdc5ff4ca558ec785118dfe1ff2864340937da8226863ff66d&server=2"))
|
||||||
|
.BDDfy();
|
||||||
|
}
|
||||||
|
|
||||||
private void GivenTheServiceProviderConfigIs(ServiceProviderConfiguration config)
|
private void GivenTheServiceProviderConfigIs(ServiceProviderConfiguration config)
|
||||||
{
|
{
|
||||||
var configuration = new InternalConfiguration(null, null, config, null, null, null, null, null);
|
var configuration = new InternalConfiguration(null, null, config, null, null, null, null, null);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user