美文网首页
用okhttp处理Http请求参数http-get~

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

作者: A徐亮波KingA | 来源:发表于2020-09-17 10:42 被阅读0次

    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~

          本文链接:https://www.haomeiwen.com/subject/foclyktx.html