mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
fix decode
This commit is contained in:
@@ -383,17 +383,19 @@ public class HttpUtilTest {
|
||||
|
||||
@Test
|
||||
public void httpParameterDecodeTest () {
|
||||
String test = "this is test测试";
|
||||
int port = NetUtil.getUsableLocalPort();
|
||||
final String test = "this is test测试";
|
||||
final int port = NetUtil.getUsableLocalPort();
|
||||
HttpUtil.createServer(port)
|
||||
.addAction("/formEncoded", (req, resp) -> resp.write(req.getParam("test")))
|
||||
.addAction("/urlEncoded", (req, resp) -> resp.write(req.getParam("test")))
|
||||
.start();
|
||||
String resp = HttpUtil.createPost(String.format("http://localhost:%s/formEncoded", port))
|
||||
|
||||
final String resp = HttpUtil.createPost(String.format("http://localhost:%s/formEncoded", port))
|
||||
.form("test", test).execute().body();
|
||||
Assert.assertEquals("Form请求参数解码", test, resp);
|
||||
String urlGet = UrlBuilder.of(String.format("http://localhost:%s/urlEncoded", port)).addQuery("test", test).build();
|
||||
String resp2 = HttpUtil.createGet(urlGet).execute().body();
|
||||
|
||||
final String urlGet = UrlBuilder.of(String.format("http://localhost:%s/urlEncoded", port)).addQuery("test", test).build();
|
||||
final String resp2 = HttpUtil.createGet(urlGet).execute().body();
|
||||
Assert.assertEquals("QueryString请求参数编码", test, resp2);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user