Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to dump http request body in resteasy & wildfly 8.2

I am looking for a way to dump http request & reaponse body (json format) in resteasy on wildfly 8.2.

I've checked this answer Dump HTTP requests in WildFly 8 but it just dumps headers.

I want to see the incoming json message and outgoing one as well.

Can configuration do it without filter or any coding?

like image 834
Chris Avatar asked Jun 22 '15 00:06

Chris


1 Answers

Logging HTTP bodies is not something frequently done. That's probably the primary reason for RequestDumpingHandler in Undertow only logging the header values. Also keep in mind that the request body is not always very interesting to log. Think for example of using WebSockets or transmitting big files. You can write your own MessageBodyReader/Writer for JAX-RS, and write to a ByteArrayOutputStream first, then log the captured content before passing it on. However, given the proven infeasibility of this in production, I think your mostly interested in how to do this during development.

You can capture HTTP traffic (and in fact any network traffic) using tcpflow or Wireshark. Sometimes people use tools such as netcat to quickly write traffic to a file. You can use for example the Chrome debugger to read HTTP requests/responses (with their contents).

like image 79
Jan-Willem Gmelig Meyling Avatar answered Nov 15 '22 04:11

Jan-Willem Gmelig Meyling