A http client library with fluent api
compile 'site.kason:fhc:2.0.0'
val client = HttpClient.newClient();
//request with GET method
try(val resp = client.get("http://kason.site")) {
assert resp.status() == 200;
val data = resp.body()?.string();
println(data);
}
val params = ["name": "fhc"];//key-value map
try (val resp = client.post("http://kason.site", params)) {
//process resp
}
val json = '''{"name":"fhc"}''';//json string
try (val resp = client.post("http://kason.site", json.getBytes("utf8")) {
//process resp
}
val client = HttpClient.config()
.httpProxy("localhost", 8888)
.httpsProxy("localhost", 8888)
.newClient();
val client = HttpClient.config()
.trustAll(true)
.newClient();