Were using okhttp3 to POST a JSON payload to a web server. We want to know the total byte count of the request and the response for the POST request. Ultimately, we want to get the data throughput. Here is the code:
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url(url)
.post(body)
.build();
mBytesSent += request.body.contentLength(); // Payload byte count
mBytesSent += request.headers().size();
mBytesSent += request.tag().toString().length();
Response response = client.newCall(request).execute()
mBytesRecd += response.body().contentLength();
mBytesRecd += response.headers().toString().length();
mBytesRecd += response.message().length();
Is this the complete byte count for a POST?