OKHttp

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

<dependency>
	<groupId>com.squareup.okhttp3</groupId>
	<artifactId>okhttp</artifactId>
	<version>3.14.2</version>
</dependency>