2

I am having @RestController with endpoint like below (spring-boot version 1.5.9.RELEASE)

@RestController
public class Controller
{
    @PostMapping(value = "profile", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
    @ResponseBody
    public Profile profile(@RequestBody Request request) {
        ... ... ...
        return profileObj;
    }
}

Whenever I invoke above endpoint, I am getting response with below headers,

.... ... ...
Access-Control-Allow-Headers:
Cache-Control: no cache, no-store, must-revalidate
Content-Type: application/json;charset=utf-8
Transfer-Encoding: chunked

I want to disable transfer-encoding, i.e, I need to include content-length.

I have many controllers like this. So I don't want to calculate length in each endpoint and return ResponseEntity with length value. I am looking for generic solution which will automatically include content-length. Is there anyway to achieve this?

Raashith
  • 155
  • 3
  • 16
  • Did you got it solved? – Ismail Aug 02 '19 at 12:10
  • @Raashith I am also interested in it. Did you happen to get it resolved? I read somewhere that using a response interceptor to set cookies / calculate and fill-in response-buffer-size (to set the `Content-Length`-attribute) is possible, but haven't tried it yet. What's the disadvantage of `Transfer-Encoding: chunked` anyway? – Igor Mar 06 '20 at 23:40

0 Answers0