kiota-java icon indicating copy to clipboard operation
kiota-java copied to clipboard

RedirectHandler appears to be redundant for default configuration

Open p-m-j opened this issue 8 months ago • 4 comments

followRedirects(false) isn't called on the default OkHttpClient builder and so redirects are followed upstream from kiota, this makes RedirectHandler a little confusing.

Forgive me If this is known and intentional, it tripped me up for a while.

p-m-j avatar Apr 02 '25 00:04 p-m-j

Hi @p-m-j Thank you for using kiota and for reaching out.

I think this is an oversight on our end, we meant to align java with the other languages, and disable the default redirection following behaviour.

Is this something you'd like to submit a pull request for provided some guidance?

baywet avatar Apr 02 '25 16:04 baywet

@baywet I'm happy to submit a PR (nice to see that the CLA setup looks pretty painless 👍).

Guide away!

p-m-j avatar Apr 02 '25 23:04 p-m-j

The factory that sets up the default http client is here.

https://github.com/microsoft/kiota-java/blob/c4684aba16e23bcfa7da4793e6f6b8233b1b8e40/components/http/okHttp/src/main/java/com/microsoft/kiota/http/KiotaClientFactory.java#L59

And you can add an additional unit test here to prevent future regressions on the setup https://github.com/microsoft/kiota-java/blob/c4684aba16e23bcfa7da4793e6f6b8233b1b8e40/components/http/okHttp/src/test/java/com/microsoft/kiota/http/KiotaClientFactoryTest.java#L33

Optional, the redirect handler does not have any unit test 😱 But if you also want to take on that extra work, you could add a new file here https://github.com/microsoft/kiota-java/tree/main/components/http/okHttp/src/test/java/com/microsoft/kiota/http/middleware

Let me know if you have any additional comments or questions.

baywet avatar Apr 03 '25 13:04 baywet

Apologies for the turnaround time @baywet, the folks that pay the bills have kept me pretty busy.

p-m-j avatar May 22 '25 16:05 p-m-j