feign-reactive icon indicating copy to clipboard operation
feign-reactive copied to clipboard

Gzip compression support not working with ReactiveOptions

Open reneeshr opened this issue 2 years ago • 1 comments

Hey @kptfh

Based on the comment from the previous issue - https://github.com/PlaytikaOSS/feign-reactive/issues/466

I tried to pass the acceptCompressed flag in the ReactiveOptions for the reactive feign client and it doesn't include the Accept-Encoding:gzip header automatically with the request.

 fun reactiveWebClientOptions(): ReactiveOptions {
        return WebReactiveOptions.Builder()
            .setReadTimeoutMillis(5000)
            .setWriteTimeoutMillis(5000)
            .setConnectTimeoutMillis(5000)
            .setAcceptCompressed(true)
            .build()
    }

Then I tried to add a client connector to compress the request according to this link, but this is not passing the Accept-Encoding:gzip header while making API request.

WebReactiveFeign.builder(
            WebClient.builder()
                .clientConnector(
                    ReactorClientHttpConnector(
                        HttpClient.create()
                            .compress(true).secure()
                    )
                )
        )

Finally, I added the Accept-Encoding header in the FeignApi client method to see if it can accept the compressed response from the server like below

@Headers("Content-Type: text/html", "Accept: text/html", "Accept-Encoding: gzip")
@RequestLine("GET /api/v1/tickets/{ticketId}/render/html")

When I enable it, I can see the Accept-Encoding headers are passing while invoking another API, however, the response headers don't contain the Content-Encoding: gzip headers, even though the server is working as expected when we test with Postman as I can see the headers are coming correctly in the response.

Could you please advise if we are missing something to enable compression on the client side for reactive? I have attached the API request/response headers trace for your reference.

[Client#apiMethod(String)] REQUEST HEADERS
Accept:[text/html]
Accept-Encoding:[gzip]
Content-Type:[text/html]
Authorization:[Basic xxxxxxxxxxxxx==]
X-REQUEST-ID:[xxxxxxxxxxxxxxxxxxxxxxxxx]
User-Agent:[Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36]
x-forwarded-for:[1000000.0000.00000]
Accept-Language:[en]

[Client#apiMethod(String)]  RESPONSE HEADERS
Cache-Control:no-cache, max-age=0, must-revalidate
Content-Type:text/html
Etag:40-xxxxxxxxxxxxxxxxxxxxxxxxx
Expires:0
Pragma:no-cache
Referrer-Policy:no-referrer
X-Content-Type-Options:nosniff
X-Frame-Options:DENY
X-Request-Id:xxxxxxxxxxxxxxxxxxxxxxxxx
X-Xss-Protection:1 ; mode=block
Date:Fri, 21 Apr 2023 08:43:57 GMT
transfer-encoding:chunked

reneeshr avatar May 02 '23 09:05 reneeshr

Check it via WebClient please

kptfh avatar Nov 15 '23 09:11 kptfh