Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gzip compression support not working with ReactiveOptions #593

Open
reneeshr opened this issue May 2, 2023 · 1 comment
Open

Gzip compression support not working with ReactiveOptions #593

reneeshr opened this issue May 2, 2023 · 1 comment

Comments

@reneeshr
Copy link

reneeshr commented May 2, 2023

Hey @kptfh

Based on the comment from the previous issue - #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
@kptfh
Copy link
Collaborator

kptfh commented Nov 15, 2023

Check it via WebClient please

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants