-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Query params aren't proxied correctly (Service Fabric) #555
Comments
var uriBuilder = new UriBuilder
{
Port = Port,
Host = Host,
Path = AbsolutePath,
Query = Query,
Scheme = Scheme
}; It probably shouldn't just assign to
|
@davidni there is a similar issue with query string params on the With regards to cmd=instance are you asking why this is being added? |
Indeed. Service Fabric Reverse Proxy doesn't seem to care about this query param, and it gets passed transparently all the way to the target service. It is problematic because it means a service behind Ocelot cannot provide functionality that relies on a query param called Makes sense? |
@davidni I think I added it because when originally making Ocelot work with SF I saw that the sf client was appending it for requests to instance services. I actually don't know SF that well so if you know we don't need it more than happy to remove!! |
Yes, let's remove it. Documentation is here A call to Reverse Proxy takes this shape: The query params shown have special meaning for Reverse Proxy. Everything else is proxied without change. |
To summarize, there are 2 specific asks for this issue:
You mentioned (1) might be a dupe of another issue. Do you recall which one? |
|
@davidni can you share your json config for this issue? I'm having trouble replicating the problem. |
If you can point me in the right direction with the commit above that could also help! |
Thanks again for your efforts to always raise the bar and improve quality. |
No worries I’m away all weekend as well so won’t be too much movement. I will try on Windows classic .net and see what happens. I really hope that is not the case! |
…ws service fabric says its not needed I
Should be fixed in 10.0.4! Let me know if any problems. |
I am experiencing the same behavior reported by @davidni wrt item 1, running Ocelot v12.0.1. I can see that the DownstreamRequest constructor sets Query = _request.RequestUri.Query, and ToHttpRequestMessage() and ToUri() both pass those values as-is to UriBuilder. The issue is that the value carries the '?' as the first character, and per the MSDN quote David referenced above, this must be manually stripped out. I'm using very simple ReRoutes rules, such as this:
...which is turning my routes from "https://localhost:5099/routing/services/ServerVersion?myparam=myvalue" into "https://localhost:23651/routing/services/ServerVersion??myparam=myvalue". Replacing the Query statement in the DownstreamRequest constructor with this, for example, resolves the issue:
I'm using Ocelot in a ASP.NET app targeting .NET Framework 4.6.1, on Win 10, VS 2017. |
Expected Behavior
Query params should be proxied correctly.
Actual Behavior
When using Service Fabric, an incoming request to
https://example.com/a?b=c
ends up being sent tohttps://localhost:19081/a??b=c&cmd=instance
. I suspect the duplicated??
problem exists without Service Fabric too.I'm surprised this hasn't been caught before since it seems very easy to encounter. Perhaps there's a way around this that I just haven't found yet (for now I have code on my side to patch up the
DownstreamContext
before making the request.Steps to Reproduce the Problem
Use a dummy rule that proxies UpstreamPath
"/{everything}"
to DownstreamPath"/{everything}"
. Make a request that matches the rule, with or without query parameters.Specifications
8.0.3
-10.0.2
The text was updated successfully, but these errors were encountered: