title: Python twisted proxyclient cascade / upstream to squid
body: <p>I would like to run a small http proxy server on my machine which sends all requests to an upstream / cascading proxy server.</p>
  
  <p>Twisted Web HTTP Proxy -> Squid -> Internet connection</p>
  
  <p>Unfortunately I cannot figure out how to send all ProxyClient requests upstream / cascade them to Squid. Could you give me a hint?</p>
  
  <p>Do I have to use reactor.connectTCP and HttpClientFactory for this and somehow direct the Squid response through?</p>
  
  <p>I have used the following Twisted code sample to get the twisted http proxy up:</p>
  
  <pre><code>from twisted.web import proxy, http
  from twisted.internet import reactor
  from twisted.python import log
  import sys
  log.startLogging(sys.stdout)
  
  class ProxyFactory(http.HTTPFactory):
      protocol = proxy.Proxy
  
  reactor.listenTCP(8080, ProxyFactory())
  reactor.run()
  </code></pre>
  
  <p>Thanks,</p>
  
  <p>Mathias</p>