From: Kenneth Reitz Date: Wed, 17 Aug 2011 07:19:46 +0000 (-0400) Subject: hijack arguments X-Git-Tag: v0.6.0~13 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=008c77c911f504cd72f7e097f1744daaadab2162;p=services%2Fpython-requests.git hijack arguments --- diff --git a/docs/user/advanced.rst b/docs/user/advanced.rst index 430a472..499c354 100644 --- a/docs/user/advanced.rst +++ b/docs/user/advanced.rst @@ -89,6 +89,37 @@ Let's print some request method arguments at runtime:: http://httpbin +Let's hijack some arguments this time:: + + def hack_headers(args): + if not args[headers]: + args['headers'] = dict() + + args['headers'].update({'X-Testing': 'True'}) + + + return args + + hooks = dict(args=hack_headers) + headers = dict(yo=dawg) + + >>> requests.get('http://httpbin/headers', hooks=hooks, headers=headers) + { + "headers": { + "Content-Length": "", + "Accept-Encoding": "gzip", + "Yo": "dawg", + "X-Forwarded-For": "::ffff:24.127.96.129", + "Connection": "close", + "User-Agent": "python-requests.org", + "Host": "httpbin.org", + "X-Testing": "True", + "X-Forwarded-Protocol": "", + "Content-Type": "" + } + } + + Verbose Logging ---------------