I am debugging a Java application which makes use of the org.apache.http.* API such :
HttpResponse response = m_httpClient.execute(head,new BasicHttpContext());
That is just one example, my project is plenty of lines like that one, I would like insert a print log which should print the content and the headers, such:
Log.i(TAG, "---> Request <-----");
String str = "";
for (Header header : post.getAllHeaders())
{
str += header.getName() + " : " + header.getValue() + "\n";
}
Log.i(TAG, str);
Log.i(TAG, "---> Response <-----");
HttpResponse response = client.execute(post);
Log.i(TAG, EntityUtils.toString(response.getEntity()));
response = client.execute(post);
As workaround to avoid the "IllegalStateException: Content has been consumed" I am performing the request twice but I really do not like that, are there solutions to avoid this ?