File: README.rst

package info (click to toggle)
wsgiproxy2 0.4.5-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 156 kB
  • sloc: python: 664; makefile: 128
file content (50 lines) | stat: -rw-r--r-- 1,293 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
Installation
============

With pip::

  $ pip install WSGIProxy2

Install optionnal backends::

  $ pip install requests restkit 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 accept some keyword arguments. Those arguments are passed
to the client during the process.

If no client as 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 <http://pypi.python.org/pypi/urllib3>`_::

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

Use `requests <http://pypi.python.org/pypi/requests>`_. This client support response streaming::

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

Use `restkit <http://pypi.python.org/pypi/restkit>`_. This client support
request and response streaming but does not support python3 (will be fixed with
the next release)::

  >>> proxy = HostProxy(application_url, client='restkit') # doctest: +SKIP