Skip to content

gawel/WSGIProxy2

Repository files navigation

Installation

With pip:

$ pip install WSGIProxy2

Install optional backends:

$ pip install requests urllib3

Usage

Create a proxy:

>>> from wsgiproxy import HostProxy
>>> proxy = HostProxy(application_url)

Then use it. Here is an example with WebOb but you can use it like a classic WSGI application:

>>> from webob import Request
>>> req = Request.blank('/form.html')
>>> resp = req.get_response(proxy)
>>> print(resp.text)
<html>...
...</html>

The Proxy application accepts some keyword arguments. Those arguments are passed to the client during the process.

If no client is specified then python httplib is used. It's recommended to use a more robust client able to manage a connection pool and stuff.

Use urllib3:

>>> proxy = HostProxy(application_url, client='urllib3')

Use requests. This client supports response streaming:

>>> proxy = HostProxy(application_url, client='requests')

About

A WSGI Proxy with various http client backends

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages