Sonique
Sonique

Reputation: 7080

ResponseEntity<JSON> - no content-length in header

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?

Upvotes: 5

Views: 8466

Answers (1)

chimmi
chimmi

Reputation: 2085

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.

Upvotes: 4

Related Questions