Skip to content

Http Client

landawn edited this page Mar 19, 2019 · 2 revisions

By the methods provided in HttpClient, it's super easy to send(get/post/put/delete...) String/Map/Entity/InputStream/Reader... request with JSON/XML... format. Here is a sample:

httpClient.post(MyResponseEntity.class, myRequestEntity, httpSettings);
//Or
HttpRequest.url(url).headers(headers).post(MyResponseEntity.class, myRequestEntity);
// Or
HttpRequest.url(url).headers(headers).post(HttpResponse.class, myRequestEntity);


// By Okhttp
okHttpClient.post(MyResponseEntity.class, myRequestEntity, httpSettings);
//Or
OKHttpRequest.url(url).headers(headers).post(MyResponseEntity.class, myRequestEntity);
// Or
OKHttpRequest.url(url).headers(headers).post(HttpResponse.class, myRequestEntity);
// Or
OKHttpRequest.url(url).headers(headers).post(okhttp3.Response.class, myRequestEntity);