Merge branch 'next-gen' of https://github.com/manuelcortez/TWBlue into next-gen

This commit is contained in:
Manuel Cortez 2017-12-14 04:59:56 -06:00
commit 2457fcf8f3

View File

@ -28,7 +28,9 @@ class URLShortener (object):
else: else:
return r.headers['location'] return r.headers['location']
else: # if the head method does not work, use get instead. Performance may decrease else: # if the head method does not work, use get instead. Performance may decrease
r=requests.get(url, allow_redirects=False) r=requests.get(url, allow_redirects=False, stream=True)
# release the connection without downloading the content, we only need the response headers
r.close()
return r.headers['location'] return r.headers['location']
except: except:
return url #we cannot expand return url #we cannot expand