mirror of
https://github.com/kennethreitz/requests.git
synced 2026-06-05 22:50:18 +00:00
+4
-1
@@ -12,6 +12,9 @@ Available hooks:
|
||||
A dictionary of the arguments being sent to Request().
|
||||
|
||||
``pre_request``:
|
||||
The Request object, directly after being created.
|
||||
|
||||
``pre_send``:
|
||||
The Request object, directly before being sent.
|
||||
|
||||
``post_request``:
|
||||
@@ -25,7 +28,7 @@ Available hooks:
|
||||
import traceback
|
||||
|
||||
|
||||
HOOKS = ('args', 'pre_request', 'post_request', 'response')
|
||||
HOOKS = ('args', 'pre_request', 'pre_send', 'post_request', 'response')
|
||||
|
||||
|
||||
def dispatch_hook(key, hooks, hook_data):
|
||||
|
||||
@@ -570,6 +570,10 @@ class Request(object):
|
||||
if cookie_header is not None:
|
||||
self.headers['Cookie'] = cookie_header
|
||||
|
||||
# Pre-send hook.
|
||||
r = dispatch_hook('pre_send', self.hooks, self)
|
||||
self.__dict__.update(r.__dict__)
|
||||
|
||||
try:
|
||||
# The inner try .. except re-raises certain exceptions as
|
||||
# internal exception types; the outer suppresses exceptions
|
||||
|
||||
Reference in New Issue
Block a user