Proxy username/password with Twisted
proxy, python, twisted
Solution
Figured out the problem, the Proxy-Authorization field has to be set in the headers:
endpoint = TCP4ClientEndpoint(reactor, host, port)
agent = ProxyAgent(endpoint)
headers = {}
auth = base64.b64encode("%s:%s" % (username, password))
headers["Proxy-Authorization"] = ["Basic " + auth.strip()]
body = agent.request("GET", path, Headers(headers))
Problem
I'm trying to use Twisted's ProxyAgent class to connect to a proxy server and make HTTP requests, however the server requires a username and password. Is it possible to specify these credentials to the server using ProxyAgent? ``` endpoint = TCP4ClientEndpoint(reactor, host, port) agent = ProxyAgent(endpoint) # Maybe need to pass auth credentials in the header here? body = agent.request("GET", path) ```