I have microservice which is written with Spring Boot and I use Zuul as API Gateway. in this microservice, I'm calling an external service which receive and get an image.
when I call that external service without Zuul being up, I receive the image correctly and I can open and see the image.
this is my code in my microservice which calls the external service:
@Override
public ResponseEntity<byte[]> getFile(String nodeId) {
String serviceUrl = this.path;
HttpHeaders headers = new HttpHeaders();
headers.setAccept(List.of(MediaType.APPLICATION_JSON));
headers.setContentType(MediaType.APPLICATION_JSON);
headers.add(Headers.NAME.value, this.name);
headers.add(Headers.PASSWORD.value, this.password);
HttpEntity<Void> requestEntity = new HttpEntity<>(headers);
return restTemplate
.exchange(serviceUrl, HttpMethod.GET, requestEntity, byte[].class);
}
this is the response that I received when I called the external service without zuul:

and this is the image which I receive:
every thing is fine until I start Zuul. after starting Zuul, now when I call that external service, I receive response like this (the colored boxes are those ones which are new in the response):
and the received file cannot be displayed and actually it is crashed and corrupted file:

after using Zuul, two things have been added to the response. Content-Type became image/jpeg;charset=UTF-8 AND there is no Content-Length in response anymore and instead, we have Transfer-Encoding with chunked value.
I removed the charset=UTF-8 with this code:
spring:
http:
encoding:
charset: utf-8
force: false
but the problem hasn't solved. so I guess that it might be related to Transfer-Encoding with chunked value.
what's wrong with this code? what should I do? why with using Zuul, the received image is damaged?
Thank you (sorry for my bad English)
Edit: I added this line to my application.yml file:
zuul.set-content-length=true
Transfer-Encoding with chunked value has been deleted and Content-Length has been added to headers BUT the file is still damaged and it took about 10 seconds (the timeout that has been specified in my application.yml for zuul- actually I changed that to 6 minutes and it take exactly 6 minutes and then result was same.) to download the image.


