Search code examples
javaspringhttprestspring-mvc

How to decode Gzip compressed request body in Spring MVC


I have a client that sends data with

CONTENT-ENCODING deflate

I have code like this

@RequestMapping(value = "/connect", method = RequestMethod.POST)
@ResponseBody
public Map onConnect(@RequestBody String body){}

Currently 'body' prints out the garbled, compressed data. Is there any way to make Spring MVC automatically uncompress it?


Solution

  • You don't handle it in Spring. Instead you use a filter so that the data arrives in Spring already deflated.

    Hopefully these two links can get you started.