0

Is is possible to set an HttpClient to follow redirection only if this is a redirection on the same domain ?

I guess we could do that by checking somehow the redirected url and manually check if it is in the same domain (not sure if we can actually do that). Or maybe there is an option I did not find to do that automatically ?

NineBerry
  • 26,306
  • 3
  • 62
  • 93
azerty
  • 698
  • 7
  • 28
  • See https://stackoverflow.com/questions/10642528/how-does-one-configure-httpclient-not-to-automatically-redirect-when-it-receives on how to disable the automatic redirect – NineBerry Aug 02 '17 at 15:57

1 Answers1

2

No, there is no option to follow just some redirects. You need to disable automatic "follow redirect" and handle 301/302 responses yourself by checking "location" header on the response.

See

Alexei Levenkov
  • 98,904
  • 14
  • 127
  • 179