0

I used HTTP client to get the status of the URL. By Default the AllowAutoRedirect is True.

It automatically process the URL redirection. But it fails if the location header returns the absolute URL.

It stops the request and return last location header url status.

Example:

URL A ("http://www.alphabets.com/a") -> Redirect -> URL B ("http://www.alphabets.com/b")

URL B ("http://www.alphabets.com/b") -> Redirect -> URL C ("http://www.alphabets.com/c")

URL C ("http://www.alphabets.com/c") -> Redirect -> URL D ("http://www.alphabets.com/d")

URL D ("http://www.alphabets.com/d")-> Redirect -> URL E ("/e") (E is relative URL)

URL D status code is returned as status code. But the actual Redirected URL is F.

is there any way to overcome this case and get URL F as the redirected one.

Note:

It can be achieved by setting AllowAutoRedirect=false and manually handle the redirection. But I want to find, is there any way to achieve this with AllowAutoRedirect=True

3
  • You’ve listed all http examples, but are some actually https? Commented May 18, 2021 at 19:57
  • It just a sample data for clarity. There might be a combination http and https or only http or only https urls received by the in the location header. Commented May 19, 2021 at 5:10
  • I suspect the redirects that remain within http or https (and all the relative paths would satisfy this), as well as the ones that redirect http -> https succeed, but the https -> http ones fail. Can you confirm? Commented May 19, 2021 at 7:12

0

Your Answer

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