As suggested by @caskey, a possible solution would be to use reflection to replace the inputBuffer with a replayable inputbuffer. But I did not use that approach as it felt naughty.
Instead I created a request wrapper in a filter which reads the inputstream into a byte array and returns a new InputStream
that internally uses a ByteArrayInputStream
around that array for all getInputStream
calls.
After reading the inputstream to the byte array, I create a parameter map by parsing the payload. I merged the superclass' parameter map in to support GET cases with query parameters. I've overridden all the getParameter*() methods to use this parameter map.
I used apache.axis.utils.IOUtils.readFully
to easily read the stream in to the byte array. And I'm currently using javax.servlet.http.HttpUtils.parsePostData
to parse the data into parameter map. HttpUtils.parsePostData
is actually deprecated, so I'll likely replace it with a better version when I find it.
But this works, yay!