use of cn.hutool.core.net.url.UrlQuery in project hutool by looly.
the class UrlQueryTest method parseTest2.
@Test
public void parseTest2() {
String requestUrl = "http://192.168.1.1:8080/pc?=d52i5837i4ed=o39-ap9e19s5--=72e54*ll0lodl-f338868d2";
UrlQuery q = new UrlQuery();
UrlQuery parse = q.parse(requestUrl, Charset.defaultCharset());
Assert.assertEquals("=d52i5837i4ed=o39-ap9e19s5--=72e54*ll0lodl-f338868d2", parse.toString());
}
use of cn.hutool.core.net.url.UrlQuery in project hutool by looly.
the class UrlQueryTest method parsePercentTest2.
@Test
public void parsePercentTest2() {
String queryStr = "signature=%2Br1ekUCGjXiu50Y%2Bk0MO4ovulK8%3D";
final UrlQuery query = UrlQuery.of(queryStr, null);
Assert.assertEquals(queryStr, query.toString());
}
use of cn.hutool.core.net.url.UrlQuery in project hutool by dromara.
the class UrlQueryTest method parsePercentTest2.
@Test
public void parsePercentTest2() {
String queryStr = "signature=%2Br1ekUCGjXiu50Y%2Bk0MO4ovulK8%3D";
final UrlQuery query = UrlQuery.of(queryStr, null);
Assert.assertEquals(queryStr, query.toString());
}
use of cn.hutool.core.net.url.UrlQuery in project hutool by dromara.
the class UrlQueryTest method parseTest4.
@Test
public void parseTest4() {
// https://github.com/dromara/hutool/issues/1989
String queryStr = "imageMogr2/thumbnail/x800/format/jpg";
final UrlQuery query = UrlQuery.of(queryStr, CharsetUtil.CHARSET_UTF_8);
Assert.assertEquals(queryStr, query.toString());
}
use of cn.hutool.core.net.url.UrlQuery in project hutool by dromara.
the class HttpRequest method urlWithParamIfGet.
/**
* 对于GET请求将参数加到URL中<br>
* 此处不对URL中的特殊字符做单独编码<br>
* 对于非rest的GET请求,且处于重定向时,参数丢弃
*/
private void urlWithParamIfGet() {
if (Method.GET.equals(method) && false == this.isRest && this.redirectCount <= 0) {
UrlQuery query = this.url.getQuery();
if (null == query) {
query = new UrlQuery();
this.url.setQuery(query);
}
// 优先使用body形式的参数,不存在使用form
if (ArrayUtil.isNotEmpty(this.bodyBytes)) {
query.parse(StrUtil.str(this.bodyBytes, this.charset), this.charset);
} else {
query.addAll(this.form);
}
}
}
Aggregations