Call hooks when following redirects #1100

Closed
wants to merge 1 commit into
from

Projects

None yet

2 participants

@jimothyGator

See #965 . However, this no longer appears to be working in Requests 1.1. This pull request is against 1.1.

@sigmavirus24
Collaborator

This should be working now after #1099. Can you test from the repo and confirm @jimothyGator?

@jimothyGator

Confirmed:

import requests

def print_respone(resp):
    print resp.status_code, resp.url

hooks = dict(response=print_respone)

requests.get('http://httpbin.org/redirect/3', hooks=hooks)

Output:

302 http://httpbin.org/redirect/3
302 http://httpbin.org/redirect/2
302 http://httpbin.org/redirect/1
200 http://httpbin.org/get
@sigmavirus24
Collaborator

Awesome. Thanks for your fix as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment