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", "*/*")
Response resp = client.newCall(req).execute();

Copyright © All Rights Reserved