[java] Quick access to the use of the http network request framework QuickHttp

In java development, we usually need to write a lot of things to request an interface. Is there a simple, convenient and powerful framework? Here we use QuickHttp framework


The open source address of the QuickHttp framework:

https://github.com/fcibook/QuickHttp


QuickHttp framework download:

In maven, add

<dependency>
    <groupId>com.fcibook.quick</groupId>
    <artifactId>quick-http</artifactId>
    <version>1.3</version>
</dependency>
Or directly download the jar package and use

https://search.maven.org/remotecontent?filepath=com/fcibook/quick/quick-http/1.3/quick-http-1.3.jar

How to use the QuickHttp framework:

String res = new QuickHttp()
               .url("http://www.csdn.net/")
               .get()
               .addParame("c", "iphone")
               .addHeader("uid","100")
               .addCookie("sid","100")
               .text();
If you are downloading a picture or a file, you can use it like this:

byte[] res = new QuickHttp()
               .url("http://www.csdn.net/")
               .post()
               .bytes();
If you need to get the returned cookie or http code, you can use it like this:

ResponseBody body = new QuickHttp()
               .url("http://www.csdn.net/")
               .post()
               .body();
int stateCode = body.getStateCode();
CookieStore cookie = body.getCookie();
String text = body.text();
String bytes = body.bytes();
In addition, the QuickHttp framework also supports the free addition of headers, cookies and other parameters, which is easy to use



Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325446650&siteId=291194637