From 2fb88924fd9ab59a0458e39ad164ac3eba86203c Mon Sep 17 00:00:00 2001 From: Jose Manuel Delicado Date: Tue, 12 Dec 2017 16:32:12 +0100 Subject: [PATCH] URL expansion and audio playback should work well together now. When calling get method, stream parameter is set to True, so the body is not downloaded. We work with response headers, the only thing we need --- src/url_shortener/shorteners/url_shortener.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/url_shortener/shorteners/url_shortener.py b/src/url_shortener/shorteners/url_shortener.py index 0b02242f..3c5fd94e 100644 --- a/src/url_shortener/shorteners/url_shortener.py +++ b/src/url_shortener/shorteners/url_shortener.py @@ -28,7 +28,9 @@ class URLShortener (object): else: return r.headers['location'] 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'] except: return url #we cannot expand