File: interceptor.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 (28 lines) | stat: -rw-r--r-- 586 bytes parent folder | download | duplicates (6)
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

Interceptor
===========

.. automodule:: wsgi_intercept.interceptor
   :members:

Example using `httplib2`, others are much the same:

.. testcode::

    import httplib2
    from wsgi_intercept.interceptor import Httplib2Interceptor


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


    def make_app():
        return app


    http = httplib2.Http()
    with Httplib2Interceptor(make_app, host='localhost', port=80) as url:
        resp, content = http.request(url)
        assert content == b'Whee'