Search in sources :

Example 1 with UrlQuery

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());
}
Also used : UrlQuery(cn.hutool.core.net.url.UrlQuery) Test(org.junit.Test)

Example 2 with UrlQuery

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());
}
Also used : UrlQuery(cn.hutool.core.net.url.UrlQuery) Test(org.junit.Test)

Example 3 with UrlQuery

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());
}
Also used : UrlQuery(cn.hutool.core.net.url.UrlQuery) Test(org.junit.Test)

Example 4 with UrlQuery

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());
}
Also used : UrlQuery(cn.hutool.core.net.url.UrlQuery) Test(org.junit.Test)

Example 5 with UrlQuery

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);
        }
    }
}
Also used : UrlQuery(cn.hutool.core.net.url.UrlQuery)

Aggregations

UrlQuery (cn.hutool.core.net.url.UrlQuery)15 Test (org.junit.Test)12 JSONObject (com.alibaba.fastjson.JSONObject)1 NodeModel (io.jpom.model.data.NodeModel)1 NodeService (io.jpom.service.node.NodeService)1