0

I'm using Python 3.7's Http Client to make an https request, which uses a corporate proxy with credentials. I'm getting socket.gai error. pls help me with on how to use proxy with credentials for http.client, also let me know If the below error mentioned is due to proxy or not

import http.client

getApi = http.client.HTTPSConnection("www.example.com")
getApi.set_tunnel(host,port)
getApi.request("GET", "/")
resp = getApi.getresponse()
print(resp.status)

The error I get

File "C:\Program Files\Python37-32\lib\socket.py", line 748, in getaddrinfo for res in _socket.getaddrinfo(host, port, family, type, proto, flags): socket.gaierror: [Errno 11004] getaddrinfo failed

Pradeep
  • 9,667
  • 13
  • 27
  • 34
  • Seems problem in your host-name. Is hostname resolving to right server? – Ajay2588 Sep 19 '19 at 09:20
  • yeah, the hostname is correct, but it needs credentials to pass through, how do I pass the credentials using http client? – Sujin Sam Arul Raj Sep 19 '19 at 09:42
  • In which format credentials to be sent, like basic auth or in plain text or a cert? Check this https://stackoverflow.com/questions/6999565/python-https-get-with-basic-authentication. Let me know if any more info is required. – Ajay2588 Sep 23 '19 at 07:23

0 Answers0