Browse Source

Merge pull request #1247 from Coramo/master

fix 'RibbonRequest' cannot to encode issues
pull/6/head
Ryan Baxter 8 years ago committed by GitHub
parent
commit
e2e7c490db
  1. 4
      spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/feign/ribbon/FeignLoadBalancer.java
  2. 18
      spring-cloud-netflix-core/src/test/java/org/springframework/cloud/netflix/feign/ribbon/FeignLoadBalancerTests.java

4
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/feign/ribbon/FeignLoadBalancer.java

@ -123,9 +123,7 @@ public class FeignLoadBalancer extends @@ -123,9 +123,7 @@ public class FeignLoadBalancer extends
request.headers());
// Apache client barfs if you set the content length
headers.remove(Util.CONTENT_LENGTH);
return new RequestTemplate().method(request.method())
.append(getUri().toASCIIString())
.body(request.body(), request.charset()).headers(headers).request();
return Request.create(request.method(),getUri().toASCIIString(),headers,request.body(),request.charset());
}
Request toRequest() {

18
spring-cloud-netflix-core/src/test/java/org/springframework/cloud/netflix/feign/ribbon/FeignLoadBalancerTests.java

@ -18,6 +18,7 @@ import static org.mockito.Mockito.when; @@ -18,6 +18,7 @@ import static org.mockito.Mockito.when;
import java.net.URI;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import org.junit.Before;
import org.junit.Test;
@ -113,4 +114,21 @@ public class FeignLoadBalancerTests { @@ -113,4 +114,21 @@ public class FeignLoadBalancerTests {
new URI("http://bar/"));
assertThat(uri, is(new URI("https://foo:443/")));
}
@Test
@SneakyThrows
public void testRibbonRequestURLEncode() {
String url = "http://foo/?name=%7bcookie";//name={cookie
Request request = Request.create("GET",url,new HashMap(),null,null);
assertThat(request.url(),is(url));
RibbonRequest ribbonRequest = new RibbonRequest(this.delegate,request,new URI(request.url()));
Request cloneRequest = ribbonRequest.toRequest();
assertThat(cloneRequest.url(),is(url));
}
}

Loading…
Cancel
Save