File: urllib3.rst

package info (click to toggle)
python-wsgi-intercept 1.13.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 560 kB
  • sloc: python: 1,390; makefile: 56; sh: 5
file content (32 lines) | stat: -rw-r--r-- 671 bytes parent folder | download | duplicates (4)
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
urllib3_intercept
==================

.. automodule:: wsgi_intercept.urllib3_intercept


Example:

.. testcode:: 

    import urllib3
    from wsgi_intercept import urllib3_intercept, add_wsgi_intercept

    pool = urllib3.PoolManager()


    def app(environ, start_response):
        start_response('200 OK', [('Content-Type', 'text/plain')])
        return [b'Whee']


    def make_app():
        return app


    host, port = 'localhost', 80
    url = 'http://{0}:{1}/'.format(host, port)
    urllib3_intercept.install()
    add_wsgi_intercept(host, port, make_app)
    resp = pool.request('GET', url)
    assert resp.data == b'Whee'
    urllib3_intercept.uninstall()