0

I was migrating the usage of apache httpclient 4.x to httpclient 5.x version and there a lot of changes in the classes and methods. This particular question is about setRelativeRedirectsAllowed() method that was present in RequestConfig class upto 4.x version. As I am moving httpclient 5.x . I was not able to find the suitable replacement for it.

final RequestConfig requestConfig = RequestConfig
          .custom()
          .setCookieSpec(CookieSpecs.STANDARD)
          .setConnectionRequestTimeout(...)
          .setConnectTimeout(...)
          .setRedirectsEnabled(true)
          .setRelativeRedirectsAllowed(true)
          .setSocketTimeout(...)
          .build();

final CloseableHttpClient client = HttpClientBuilder
          .create()
          .setDefaultRequestConfig(requestConfig)
          .build()

final HttpComponentsClientHttpRequestFactory factory = new HttpComponentsClientHttpRequestFactory(client);

I have provided the sample example of how we are using it in our code.

I have tried going through the migration document, there was not any mention of it. I also looked at the code of apache-httpcomponents 4.x and spring 5.3.x to see if I could find how exactly it was being used, I couldn't.

My questions are, Is there a suitable replacement present for that method (setRelativeRedirectsAllowed()) in httpclient 5.x, If not, is there a way to custom implement it?

1 Answer 1

1

You don't need anything as a replacement. It supports both relative and absolute redirects out-of-the-box now. This has been addressed in this commit (you gotta love some code archaeology :) ).

So in short there is no replacement and relative redirects should just work (tm).

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.