0

I am using the python requests library for a GET request.
The request goes via a proxy and I want to set a proxy header in the request (X-AUTH)
I could not find a way to set proxy header in requests. I want something similar to --proxy-header in curl. Setting it in normal headers does not seem to work.

import requests

proxies = {
 "http": "http://myproxy:8000",
 "https": "http://myproxy:8000",
}
r = requests.get("https://abc.xyz.com/some/endpoint", proxies=proxies, headers = {"X-AUTH": "mysecret"})
print(r.text)

I have changed the endpoints for privacy. Curl call works when --proxy-header is used.

  • perhaps this will help you https://stackoverflow.com/questions/13506455/how-to-pass-proxy-authentication-requires-digest-auth-by-using-python-requests there are both basic and digest auth methods explained – bathman May 01 '20 at 14:06
  • @bathman Not sure if what I am trying to achieve is DigestAuth, I am just trying to set a custom proxy header. It can be anything 'abc': 'somevalue'... Is there anything similar to --proxy-header in requests. I took a look at urllib3.ProxyManager but even there the headers seem to be only for auth. Is there any way to do this? – Arati Kulkarni May 03 '20 at 10:35

0 Answers0