Skip to content
Myr

hijack arguments

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Kenneth Reitz · committed by Kenneth Reitz · parent 77b3768 · Browse files · 1 file+31 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+31 added−0 removed

  • other:+31 added−0 removed

1 file+31 added−0 removed

modified:docs/user/advanced.rst+31 added
87 unmodified lines
88 >>> requests.get('http://httpbin', hooks=dict(args=print_url))89 http://httpbin90 <Response [200]>9192Let's hijack some arguments this time::9394 def hack_headers(args):95 if not args[headers]:96 args['headers'] = dict()9798 args['headers'].update({'X-Testing': 'True'})99100101 return args102103 hooks = dict(args=hack_headers)104 headers = dict(yo=dawg)105106 >>> requests.get('http://httpbin/headers', hooks=hooks, headers=headers)107 {108 "headers": {109 "Content-Length": "",110 "Accept-Encoding": "gzip",111 "Yo": "dawg",112 "X-Forwarded-For": "::ffff:24.127.96.129",113 "Connection": "close",114 "User-Agent": "python-requests.org",115 "Host": "httpbin.org",116 "X-Testing": "True",117 "X-Forwarded-Protocol": "",118 "Content-Type": ""119 }120 }121122123124Verbose Logging125---------------126127If you want to get a good look at what HTTP requests are being sent
8 unmodified lines