Skip to content
Myr

Move pre_request to a more usable place, followup to #382

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

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.

authored by Christopher Grebs · committed by Christopher Grebs · parent 3cc6aca · Browse files · 1 file+4 added−4 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+4 added−4 removed

  • other:+4 added−4 removed

1 file+4 added−4 removed

modified:requests/models.py+4 added-4 removed
406 unmodified lines
407408 # Build the URL409 url = self.full_url410411 # Pre-request hook.412 r = dispatch_hook('pre_request', self.hooks, self)413 self.__dict__.update(r.__dict__)414415 # Logging416 if self.config.get('verbose'):417 self.config.get('verbose').write('%s %s %s\n' % (418 datetime.now().isoformat(), self.method, url
121 unmodified lines
540541 # Attach Cookie header to request.542 self.headers['Cookie'] = cookie_header543540 # Pre-request hook.541 r = dispatch_hook('pre_request', self.hooks, self)542 self.__dict__.update(r.__dict__)543544 try:545 # The inner try .. except re-raises certain exceptions as546 # internal exception types; the outer suppresses exceptions547 # when safe mode is set.
255 unmodified lines