Prevent Redirects for a python request to a .shtml link

49 views Asked by At

I am making a python request to a .shtml link. I want the request to not allow redirects. I am using the following command for this purpose.

response = requests.request("POST", url, headers=headers, data=payload, allow_redirects=False)

However, it gets redirected despite the allow_redirects option set to false. The same .shtml URL returns 302 response on the browser, but it returns 200 with the above python request. I want a possible way to stop the request from getting redirected, just like it's happening on the browser. Moreover, the response.history returns an empty list.

1

There are 1 answers

0
Muhammad Zubair On

The python requests deal .shtml the same way it deals with .html. In my case, the issue was with the URL.