Skip to content
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 parameters with embedded json cause error during filtering in Zuul #995

Closed
hhymarco opened this issue Apr 27, 2016 · 4 comments
Closed

Comments

@hhymarco
Copy link

hhymarco commented Apr 27, 2016

if request's method is GET,and query parameters have json data,like:

http://localhost:9995/rp-redpacket/redpackets.rp?data={%22userId%22:312565121,%22cmd%22:%22Redpacket000001%22,%22version%22:%221.0.0%22}&callback=jsonp2

zuul's RibbonRoutingFilter will occur ZuulException:

Caused by: javax.ws.rs.core.UriBuilderException: java.net.URISyntaxException: Illegal character in query at index 48: http://192.168.20.61:9006/redpackets.rp?data=%7B"userId":312565121,"cmd":"Redpacket000001","version":"1.0.0"%7D
    at com.sun.jersey.api.uri.UriBuilderImpl.createURI(UriBuilderImpl.java:723)
    at com.sun.jersey.api.uri.UriBuilderImpl._build(UriBuilderImpl.java:651)
    at com.sun.jersey.api.uri.UriBuilderImpl.build(UriBuilderImpl.java:641)
    at com.sun.jersey.api.client.WebResource.<init>(WebResource.java:88)
    at com.sun.jersey.api.client.WebResource.queryParam(WebResource.java:443)
    at com.netflix.niws.client.http.RestClient.execute(RestClient.java:598)
    at com.netflix.niws.client.http.RestClient.execute(RestClient.java:527)
    at com.netflix.niws.client.http.RestClient.execute(RestClient.java:92)
    at com.netflix.client.AbstractLoadBalancerAwareClient$1.call(AbstractLoadBalancerAwareClient.java:109)
    at com.netflix.loadbalancer.reactive.LoadBalancerCommand$3$1.call(LoadBalancerCommand.java:303)
    at com.netflix.loadbalancer.reactive.LoadBalancerCommand$3$1.call(LoadBalancerCommand.java:287)
    ... 155 common frames omitted
Caused by: java.net.URISyntaxException: Illegal character in query at index 48: http://192.168.20.61:9006/redpackets.rp?data=%7B"userId":312565121,"cmd":"Redpacket000001","version":"1.0.0"%7D
    at java.net.URI$Parser.fail(URI.java:2848)
    at java.net.URI$Parser.checkChars(URI.java:3021)
    at java.net.URI$Parser.parseHierarchical(URI.java:3111)
    at java.net.URI$Parser.parse(URI.java:3053)
    at java.net.URI.<init>(URI.java:588)
    at com.sun.jersey.api.uri.UriBuilderImpl.createURI(UriBuilderImpl.java:721)`

version is Brixton.RC2

@dsyer dsyer changed the title Zuul query parameters have json cause error during filtering Query parameters with embedded json cause error during filtering in Zuul May 3, 2016
@dsyer
Copy link
Contributor

dsyer commented May 3, 2016

That's pretty unpleasant to have to use on the client side as well. I suggest maybe a POST would be better?

@hhymarco
Copy link
Author

hhymarco commented May 3, 2016

Unfortunately it's a jsonp request

@dsyer
Copy link
Contributor

dsyer commented May 3, 2016

I still think it's ugly for the client. Can't you refactor your endpoint to accept parameters in a different format?

@spencergibb
Copy link
Member

Duplicates #918

The workaround is

    @Bean
    public RibbonCommandFactory<?> ribbonCommandFactory(
            final SpringClientFactory clientFactory) {
        return new HttpClientRibbonCommandFactory(clientFactory);
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants