GitXplorerGitXplorer
a

httproxy

public
24 stars
13 forks
5 issues

Commits

List of commits on branch master.
Unverified
d5a6b0f0e7455069e525518e08afdac8fd3bb1e6

fightning bitrot with commits

aambv committed 10 years ago
Unverified
2779b2af667bc864ba335f249e2c73dbd092aaa2

fixes issue #2, thanks Rune Hansen!

aambv committed 12 years ago
Unverified
6b07e99a1b9e022a1edd40c4582e686152a18f6e

added a test harness

aambv committed 12 years ago
Unverified
b2f8b42bd23b2339f2535e9b8d99a0745ab39eaa

fixed trove classifiers

aambv committed 12 years ago
Unverified
5a21d088f158e7ffaca22077d93bd79a1cec274b

readme updated

aambv committed 12 years ago
Unverified
c51faa8618cfc4f337b2ce1e6a934e0e12f78cd4

proper shutdown also with SIGHUP and SIGTERM

aambv committed 12 years ago

README

The README file for this repository.

httproxy

This module implements a tiny threaded HTTP proxy by extending HTTPServer. Supports the GET, HEAD, POST, PUT, DELETE and CONNECT methods.

The latest version can be installed via PyPI <http://pypi.python.org/pypi/httproxy/>_::

$ pip install httproxy

or::

$ easy_install httproxy

The source code repository <http://github.com/ambv/httproxy>_ and issue tracker <http://github.com/ambv/httproxy/issues>_ are maintained on GitHub <http://github.com/ambv/httproxy>_.

Quickstart

Usage::

httproxy [options] httproxy [options] ...

Options::

-h, --help Show this screen. --version Show version and exit. -H, --host HOST Host to bind to [default: 127.0.0.1]. -p, --port PORT Port to bind to [default: 8000]. -l, --logfile PATH Path to the logfile [default: STDOUT]. -i, --pidfile PIDFILE Path to the pidfile [default: httproxy.pid]. -d, --daemon Daemonize (run in the background). The default logfile path is httproxy.log in this case. -c, --configfile CONFIGFILE Path to a configuration file. -v, --verbose Log headers.

To start the proxy server and bind it to port 22222 (the port on which it will listen and accept connections)::

httproxy -p 22222

To start the proxy server, bind it to port 22222 and tell it to log all requests to the file httproxy.log::

httproxy -p 22222 -l httproxy.log

To start the proxy server so it only allows connections from IP 123.123.123.123::

httproxy 123.123.123.123

To start the proxy server bound to port 22222, log to file httproxy.log and run the server in the background (as a daemon)::

httproxy -p 22222 -l httproxy.log -d

Configuration file

Every option stated as a command-line argument can be passed using a configuration file. httproxy looks for the following files to read configuration:

  • /etc/httproxy/config

  • $HOME/.httproxy/config (or %HOME%\.httproxy\config on Windows)

  • the value specified in --configfile on command-line

The names of the settings in the main section are derived from the long command line option names.

The allowed-clients section holds a list of hostnames that can access the proxy, one hostname per line. Remove this section or leave empty to allow any client to connect.

An example file::

[main] host = localhost port = 8011 logfile = /Users/ambv/.httproxy/log pidfile = /Users/ambv/.httproxy/pid daemon = yes verbose = yes

[allowed-clients] localhost 192.168.0.1

Note: command-line options have precedence over configuration file settings.

Optional dependencies

If you install setproctitle, the name of the process reported by ps will be more descriptive.

If you install psutil, httproxy will be able to automatically remove stale pidfiles on startup.

Change Log

0.9.1


* fixed `issue #2 <https://github.com/ambv/httproxy/pull/2>`_: ``KeyError`` if
  there's no ``[main]`` section in ``~/.httproxy/config``. Thanks to Rune
  Hansen for the report and initial patch.

* fixed hang on shutdown due to blocking ``handle_request()``

* fixed installability on PyPy

* removed the unholy frame-walking signal handling

* updated the test suite so it works with new virtualenvs

0.9.0
  • ability to read configuration from a file (--configfile)

  • ability to specify the address the proxy will bind to (--host)

  • ability to log headers sent and received (--verbose)

  • better process management: pidfile support, a more descriptive process title (with the optional setproctitle dependency)

  • fixed spurious [Errno 54] Connection reset by peer tracebacks

  • properly shuts down when receiving SIGHUP, SIGINT or SIGTERM

  • major code refactoring

  • compatible with Python 2.6 and 2.7 only: requires docopt and configparser

0.3.1


* added rudimentary FTP file retrieval

* added custom logging methods

* added code to make it run as a standalone application

Upgraded by `Mitko Haralanov
<http://www.voidtrance.net/2010/01/simple-python-http-proxy/>`_ in 2009.

0.2.1

Authors

Script based on work by Suzuki Hisao and Mitko Haralanov, currently maintained by Łukasz Langa <mailto:lukasz@langa.pl>_.