Grails extract body data from the request

Viewed 4991

I have some controller (ExampleController) that receives requests with content-type application/x-www-form-urlencoded.

I need to send all the request data to a different URL using POST request. The data needs to be in the same order as received it.

Problem is that the content does not match because request.getParameterMap() destroys the order of the data. In ExampleController:

def method(){ 
    String s = request.reader.text //this is empty, need a way to read this text
    Map<String, String[]> vars = request.getParameterMap() //it's not good for me   because the map is unordered map 
    //but it full of data

}

which does not work.

I need something like:

byte[] data = request.getRequestData()
wr.write(data)

btw i've tried:

InputStream = request.getInputStream()
byte [] bytes = inputStream.getBytes()

I've also tried

String s = request.reader.text

but the string is empty. I think the main problem is that grails mechanism reads the input stream before the controller even starts and place the data in the parameters hashMap. is there a way to undo it?

Any help will be greatly appreciated

1 Answers
Related