Skip to content

Loading…

Fix #1106 #1117

Merged
merged 2 commits into from

2 participants

@sigmavirus24
Collaborator

The only place it makes sense to call dispatch_hook is in the session. Having them performed in the adapter does nothing as is and would be inconsistent across other adapters (ostensibly written by others).

@sigmavirus24
Collaborator

This also in part is relying on #1099.

@kennethreitz

Use case was digest auth with a prepared request sent through a connection not installed in a session.


You are right :)

@kennethreitz kennethreitz merged commit 1a87f15 into kennethreitz:master

1 check passed

Details default The Travis build passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 19, 2013
  1. @sigmavirus24

    Fix #1106

    sigmavirus24 committed
Commits on Jan 22, 2013
  1. @sigmavirus24

    Fix failing tests.

    sigmavirus24 committed
Showing with 5 additions and 4 deletions.
  1. +0 −3 requests/adapters.py
  2. +5 −1 requests/sessions.py
View
3 requests/adapters.py
@@ -13,7 +13,6 @@
from .models import Response
from .packages.urllib3.poolmanager import PoolManager, ProxyManager
from .packages.urllib3.response import HTTPResponse
-from .hooks import dispatch_hook
from .compat import urlparse, basestring, urldefrag
from .utils import (DEFAULT_CA_BUNDLE_PATH, get_encoding_from_headers,
prepend_scheme_if_needed)
@@ -109,8 +108,6 @@ def build_response(self, req, resp):
response.request = req
response.connection = self
- # Run the Response hook.
- response = dispatch_hook('response', req.hooks, response)
return response
def get_connection(self, url, proxies=None):
View
6 requests/sessions.py
@@ -275,6 +275,10 @@ def request(self, method, url,
# Prepare the Request.
prep = req.prepare()
+ # If auth hooks are present, they aren't passed to `dispatch_hook`
+ # As such, we need to update the original hooks dictionary with them
+ hooks.update(prep.hooks)
+
# Send the request.
resp = self.send(prep, stream=stream, timeout=timeout, verify=verify, cert=cert, proxies=proxies)
@@ -295,7 +299,7 @@ def request(self, method, url,
resp.history = tuple(history)
# Response manipulation hook.
- self.response = dispatch_hook('response', hooks, resp)
+ resp = dispatch_hook('response', hooks, resp)
return resp
Something went wrong with that request. Please try again.