Skip to content

Instantly share code, notes, and snippets.

@ericfrederich
Created June 11, 2014 17:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ericfrederich/e1225e2d07e3ee923b27 to your computer and use it in GitHub Desktop.
Save ericfrederich/e1225e2d07e3ee923b27 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import sys
port = int(sys.argv[1])
import requests
s = requests.session()
base_url = 'http://localhost:%d' % port
print '-------- request /old'
r = s.get(base_url + '/old')
print '-------- redirection path'
print [h.headers['location'] for h in r.history]
print '-------- 3 more /old requests'
for i in range(3):
r = s.get('http://localhost:8000/old')
print '-------- requesting /new'
r = s.get(base_url + '/new')
print '-------- requesting /newer'
r = s.get(base_url + '/newer')
print '-------- requesting /newest'
r = s.get(base_url + '/newest')
print '-------- bye'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment