forked from OpenFeign/feign
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix the issue encountered when the value of queries starting with '{' (…
…OpenFeign#555) support the query values starting with {, when use RibbonClient。different from OpenFeign#540.
- Loading branch information
1 parent
d7f40f5
commit 82b57a3
Showing
2 changed files
with
50 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package feign.ribbon; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import java.net.URI; | ||
import java.net.URISyntaxException; | ||
import java.nio.charset.Charset; | ||
import java.util.Collection; | ||
import java.util.LinkedHashMap; | ||
import java.util.Map; | ||
|
||
import org.junit.Test; | ||
|
||
import feign.Request; | ||
import feign.ribbon.LBClient.RibbonRequest; | ||
|
||
public class LBClientTest { | ||
|
||
@Test | ||
public void testRibbonRequest() throws URISyntaxException { | ||
// test for RibbonRequest.toRequest() | ||
// the url has a query whose value is an encoded json string | ||
String urlWithEncodedJson = "http://test.feign.com/p?q=%7b%22a%22%3a1%7d"; | ||
String method = "GET"; | ||
URI uri = new URI(urlWithEncodedJson); | ||
Map<String, Collection<String>> headers = new LinkedHashMap<String, Collection<String>>(); | ||
// create a Request for recreating another Request by toRequest() | ||
Request requestOrigin = Request.create(method, uri.toASCIIString(), headers, null, Charset.forName("utf-8")); | ||
RibbonRequest ribbonRequest = new RibbonRequest(null, requestOrigin, uri); | ||
|
||
// use toRequest() recreate a Request | ||
Request requestRecreate = ribbonRequest.toRequest(); | ||
|
||
// test that requestOrigin and requestRecreate are same except the header 'Content-Length' | ||
// ps, requestOrigin and requestRecreate won't be null | ||
assertThat(requestOrigin.toString()).isEqualTo(String.format("%s %s HTTP/1.1\n", method, urlWithEncodedJson)); | ||
assertThat(requestRecreate.toString()).isEqualTo(String.format("%s %s HTTP/1.1\nContent-Length: 0\n", method, urlWithEncodedJson)); | ||
} | ||
} |