用okhttp处理Http请求参数http-get~

2020-09-17  本文已影响0人  A徐亮波KingA

https://square.github.io/okhttp/3.x/okhttp/okhttp3/HttpUrl.html

HttpUrl url = new HttpUrl.Builder()
       .scheme("https")
       .host("www.google.com")
       .addPathSegment("search")
       .addQueryParameter("q", "polar bears")
       .build();
   System.out.println(url);

HttpUrl url = HttpUrl.parse("https://twitter.com/search?q=cute%20%23puppies&f=images");
   for (int i = 0, size = url.querySize(); i < size; i++) {
     System.out.println(url.queryParameterName(i) + ": " + url.queryParameterValue(i));
   }

HttpUrl url = HttpUrl.parse("http://who-let-the-dogs.out").newBuilder()
       .addPathSegment("_Who?_")
       .query("_Who?_")
       .fragment("_Who?_")
       .build();
   System.out.println(url);
上一篇 下一篇

猜你喜欢

热点阅读