Skip to content
Myr

Provide new register_hook system.

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

#372

authored by Kenneth Reitz · committed by Kenneth Reitz · parent e9be7c1 · Browse files · 1 file+17 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+17 added−4 removed

  • other:+17 added−4 removed

1 file+17 added−4 removed

modified:requests/models.py+17 added-4 removed
11 unmodified lines
1213from urlparse import urlparse, urlunparse, urljoin, urlsplit14from datetime import datetime1516from .hooks import dispatch_hook16from .hooks import dispatch_hook, HOOKS17from .structures import CaseInsensitiveDict18from .status_codes import codes19from .packages import oreos20from .auth import HTTPBasicAuth, HTTPProxyAuth
92 unmodified lines
113 #: True if Request has been sent.114 self.sent = False115116 #: Event-handling hooks.117 self.hooks = hooks117 self.hooks = {}118119 for event in HOOKS:120 self.hooks[event] = []121122 hooks = hooks or {}123124 for (k, v) in hooks.items():125 self.register_hook(event=k, hook=v)126127 #: Session.128 self.session = session129130 #: SSL Verification.
219 unmodified lines
350351 return ''.join(url)352353354 def register_hook(self, event, hook):355 """Properly register a hook."""356357 return self.hooks[event].append(hook)358359360 def send(self, anyway=False, prefetch=False):361 """Sends the request. Returns True of successful, false if not.362 If there was an HTTPError during transmission,363 self.response.status_code will contain the HTTPError code.
176 unmodified lines
540 # If prefetch is True, mark content as consumed.541 if prefetch:542 # Save the response.543 self.response.content531 544545 if self.config.get('danger_mode'):546 self.response.raise_for_status()547548 return self.sent
79 unmodified lines
628 if not chunk:629 break630 yield chunk631 self._content_consumed = True619 632633 def generate_chunked():634 resp = self.raw._original_response635 fp = resp.fp636 if resp.chunk_left is not None:
125 unmodified lines