Netflix / zuul

Zuul is a gateway service that provides dynamic routing, monitoring, resiliency, security, and more.
Apache License 2.0
13.44k stars 2.37k forks source link

Zuul is removing Content-Encoding header for deflate, gzip. #547

Open raju4392000 opened 5 years ago

raju4392000 commented 5 years ago

Hello, Does anyone faced the below issue? we are using Netflix/ Zuul versions "com.netflix.zuul:zuul-core:1.3.1" "com.netflix.zuul:zuul-netflix:1.3.1"

When I hit a request from my service directly like shown below, it provides content-encoding header. curl “http://10.0.0.xxx:8080/myService/feature” -H "accept-encoding: deflate,gzip" -v

User-Agent: curl Accept: / accept-encoding: deflate,gzip

< HTTP/1.1 200 OK < Date: Fri, 9 Nov 2018 16:03:17 GMT < content-type: application/json < connection: keep-alive < content-encoding: gzip < content-length: 1003

But, when I hit the same service via Zuul, it removes the content-encoding header. we need to ensure it doesn't remove content-encoding header.

User-Agent: curl Accept: /

< HTTP/1.1 200 OK < Content-Type: application/json;charset=UTF-8 < Date: Fri, 9 Nov 2018 16:07:29 GMT < X-Zuul: zuul < Content-Length: 1003 < Connection: keep-alive

mauricioadlima commented 4 years ago

To solve this problem I added a filter to force add content-encoding.

RequestContext ctx = RequestContext.getCurrentContext(); HttpServletRequest request = ctx.getRequest();

String receivedContentEncoding = request.getHeader(CONTENT_ENCODING_KEY);

if (StringUtils.isNotBlank(receivedContentEncoding)) { ctx.addZuulRequestHeader(CONTENT_ENCODING_KEY, receivedContentEncoding); }