When, I return ResponseEntity<byte[]>(new ResponseEntity<byte[]>(sb.toString().getBytes(), headers, HttpStatus.OK)) from REST API, it takes about 6 seconds but when I return responseEntity.getBody(), it takes about 1 seconds. How ?
ResponseEntity<byte[]> responseEntity = configTemplateService.getConfigTemplateExample(type);
// This need very long time
return responseEntity;
ResponseEntity<byte[]> responseEntity = configTemplateService.getConfigTemplateExample(type);
// This need less time
return responseEntity.getBody();
Data type of responseEntity.getBody() is String (1).
Data type of responseEntity is binary data (2) including Body and another parts those are not Body (such as Header).
(2) = (1) + (another parts)
therefore, (2) > (1)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With