| 1 |
# Copyright (c) Twisted Matrix Laboratories. |
| 2 |
# See LICENSE for details. |
| 3 |
|
| 4 |
""" |
| 5 |
This example demonstrates a very simple HTTP proxy. |
| 6 |
|
| 7 |
Usage: |
| 8 |
$ python proxy.py |
| 9 |
|
| 10 |
Then configure your web browser to use localhost:8080 as a proxy, and visit a |
| 11 |
URL (This is not a SOCKS proxy). When browsing in this configuration, this |
| 12 |
example will proxy connections from the browser to the server indicated by URLs |
| 13 |
which are visited. |
| 14 |
|
| 15 |
See also logging-proxy.py for a proxy with additional features. |
| 16 |
""" |
| 17 |
|
| 18 |
from twisted.internet import reactor |
| 19 |
from twisted.web import http, proxy |
| 20 |
|
| 21 |
|
| 22 |
class ProxyFactory(http.HTTPFactory): |
| 23 |
def buildProtocol(self, addr): |
| 24 |
return proxy.Proxy() |
| 25 |
|
| 26 |
|
| 27 |
reactor.listenTCP(8080, ProxyFactory()) |
| 28 |
reactor.run() |