4
votes

I'm making simple http service with Spring Boot RestController, and what I was found, when I try to request via GET Json object I didn't get content-length in header and transfer-encoding becomes chunked.

With simple ResponseEntit<String> all headers set as expected.

What kind of problem may lead to this behavior?

1
ResponseEntity is meant to represent the entire HTTP response. You can control anything that goes into it: status code, headers, and body.Amit K Bist
Hi, @Sonique, do you find out what the problem was. I am experiencing something similar now.omrsin

1 Answers

4
votes

Ths is not a problem, Transfer-encoding chuncked and no content length means that response was compressed. If compression is enabled in Spring boot it will compress responses larger than certain amount (2048 bytes by default). I think your ResponseEntit<String> is simply smaller than required for compression.

You can read more about compression settings in documentation.

If you want consistency you can either disable compressing, or set server.compression.min-response-size to a very small value. But I would suggest to keep it as is.