title: OKHTTP: How to measure total bytes in Request and Response?
body: <p>Were using <code>okhttp3</code> to <code>POST</code> a <code>JSON</code> payload to a web server.  We want to know the total byte count of the request and the response for the <code>POST</code> request.  Ultimately, we want to get the data throughput.  Here is the code:</p>
  
  <pre><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();
  </code></pre>
  
  <p>Is this the complete byte count for a <code>POST</code>?</p>