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

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);

你可能感兴趣的:(用okhttp处理Http请求参数http-get~)