File: httplib2.rst

package info (click to toggle)
python-wsgi-intercept 0.8.1-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 288 kB
  • ctags: 201
  • sloc: python: 710; makefile: 180
file content (30 lines) | stat: -rw-r--r-- 669 bytes parent folder | download | duplicates (3)
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
httplib2_intercept
==================

.. automodule:: wsgi_intercept.httplib2_intercept

Example:

.. testcode:: 

    import httplib2
    from wsgi_intercept import httplib2_intercept, add_wsgi_intercept


    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)
    httplib2_intercept.install()
    add_wsgi_intercept(host, port, make_app)
    http = httplib2.Http()
    resp, content = http.request(url)
    assert content == b'Whee'
    httplib2_intercept.uninstall()