OKHttp is an easy to use http library with very few dependencies. It is also the provided library that loadcoder uses to generate loadtests.
Create the OKHttp client like this:
OkHttpClient client = new OkHttpClient();
Below shows how to create and send a request, with HTTP verb, body and headers set.
RequestBody body = RequestBody.create(MediaType.get("application/x-www-form-urlencoded; charset=UTF-8"), "http body"); Request req = new Request.Builder().url("https://localhost:8080/") .method("POST", body) .header("accept", "*/*") .build(); Response resp = client.newCall(req).execute();
Here are the Maven dependencies you need to use OKHttp as the client library for your load tests
com.squareup.okhttp3 okhttp 3.14.2