Skip to content
Advertisement

How do I print the content of httprequest request?

I’ve got a bug involving httprequest, which happens sometimes, so I’d like to log HttpGet and HttpPost request’s content when that happens.

So, let’s say, I create HttpGet like this:

JavaScript

This is the string representation that I’d like to get:

JavaScript

With the post request, I’d also like to get the content string.

What is the easiest way to do it in java for android?

Advertisement

Answer

You can print the request type using:

JavaScript

You can print all the headers as mentioned here:

JavaScript

To print all the request params, use this:

JavaScript

request is the instance of HttpServletRequest

You can beautify the outputs as you desire.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement