Commit e2e7c490 by Ryan Baxter Committed by GitHub

Merge pull request #1247 from Coramo/master

fix 'RibbonRequest' cannot to encode issues
parents 68cf3460 2db2a033
...@@ -123,9 +123,7 @@ public class FeignLoadBalancer extends ...@@ -123,9 +123,7 @@ public class FeignLoadBalancer extends
request.headers()); request.headers());
// Apache client barfs if you set the content length // Apache client barfs if you set the content length
headers.remove(Util.CONTENT_LENGTH); headers.remove(Util.CONTENT_LENGTH);
return new RequestTemplate().method(request.method()) return Request.create(request.method(),getUri().toASCIIString(),headers,request.body(),request.charset());
.append(getUri().toASCIIString())
.body(request.body(), request.charset()).headers(headers).request();
} }
Request toRequest() { Request toRequest() {
......
...@@ -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.net.URI;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
...@@ -113,4 +114,21 @@ public class FeignLoadBalancerTests { ...@@ -113,4 +114,21 @@ public class FeignLoadBalancerTests {
new URI("http://bar/")); new URI("http://bar/"));
assertThat(uri, is(new URI("https://foo:443/"))); 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));
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment