http - python requests - remove headers on redirect -
i'm using python requests library http checking on application. have situation need send in initial host header on requests, should not used when following redirects causing problem.
i've had around request docs can't see way can have requests drop request headers when following redirects.
here example of problem
import requests requests.structures import caseinsensitivedict s = requests.session() request_headers = caseinsensitivedict() request_headers['host'] = 'google.co.uk' response = s.get("http://google.co.uk",allow_redirects=true,headers=request_headers)
in case google.co.uk redirect https://www.google.co.uk, stuck in loop because send host header set 'google.co.uk' after follows redirect.
i need use manual host header on first request due going through cdn uses header determine site serving for. removing initial request not option.
here equivalent curl, drop host header after initial request. behaviour see / expect python requests
curl -h "host: google.co.uk" http://google.co.uk -l -o /dev/null
Comments
Post a Comment