Skip to main content

`requests-dump` provides hook functions for requests.

Project description

Provides a hook function to dump HTTP communiation for requests.

Please, Please, Please note that this library is in pre-alpha phase and its interface is subject to change.

Usage

You may pass the hook function to a requests’ method function.

>>> import requests
>>> import reqdump
>>> requests.get('http://example.com/', hooks=dict(response=reqdump.dump))
> GET http://example.com/
> Accept-Encoding: gzip, deflate, compress
> Accept: */*
> User-Agent: python-requests/2.2.1 CPython/2.7.6 Darwin/13.0.2

< 200 OK
< content-length: 1270
< x-ec-custom-error: 1
< x-cache: HIT
< accept-ranges: bytes
< expires: Tue, 11 Feb 2014 13:41:46 GMT
< server: ECS (sjc/4FB4)
< last-modified: Fri, 09 Aug 2013 23:54:35 GMT
< etag: "359670651"
< cache-control: max-age=604800
< date: Tue, 04 Feb 2014 13:41:46 GMT
< content-type: text/html
<!doctype html>
<html>
(... snip ...)
<Response [200]>
>>>

You can also apply patch to all requests’ method functions to use the hook function.

>>> import requests
>>> import reqdump
>>> reqdump.patch()
>>> requests.get('http://example.com/')
> GET http://example.com/
> Accept-Encoding: gzip, deflate, compress
(... snip ...)
<Response [200]>
>>> reqdump.unpatch()  # discard patches
>>> requests.get('http://example.com/')
<Response [200]>
>>>

History

0.1.3

  • Rename patch() with patch_all() and unpatch() with unpatch_all()

  • Support HTTP methods other than GET

0.1.2

  • Add patch() and unpatch() functions

0.1.1

  • Support Python 3.3

0.1

  • Birth!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

requests-dump-0.1.3.tar.gz (2.6 kB view hashes)

Uploaded Source

Built Distributions

requests_dump-0.1.3-py3.3.egg (2.4 kB view hashes)

Uploaded Source

requests_dump-0.1.3-py2.7.egg (2.4 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page