Having the hook called so late makes it impossible to overwrite the HTTP request
calling behavior and set self.sent to True in case of possible cache matches
for example.
This way we can interfere before we waste any CPU time to calculate
a request.
# Build the URL
url = self.full_url
+ # Pre-request hook.
+ r = dispatch_hook('pre_request', self.hooks, self)
+ self.__dict__.update(r.__dict__)
+
# Logging
if self.config.get('verbose'):
self.config.get('verbose').write('%s %s %s\n' % (
# Attach Cookie header to request.
self.headers['Cookie'] = cookie_header
- # Pre-request hook.
- r = dispatch_hook('pre_request', 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