Is there a way to get raw http request stream from Java servlet handler?

http, java, request

Solution

No, servlets provide no api to get at the raw request - you might need a sniffer like wireshark for that.

You can get at the parsed request headers and uri though:

- getHeaderNames()

- getRequestURI()

etc.

Problem

I am trying to put some logging to capture the raw http request coming to my application. My Java code is inside a SpringMVC controller. I have access to the "HttpServletRequest" object. But I could not find a way to get the raw http request stream out of it. There is a reader but only reads the post content. What I want is the whole shebang, the url, the headers, the body. Is there an easy way to do this? Thanks in advance.

Original source