<commit_before>import httplib
import urlparse

def unshorten_me(url):
    parsed = urlparse.urlparse(url)
    h = httplib.HTTPConnection(parsed.netloc)
    h.request('HEAD', parsed.path)
    response = h.getresponse()
    if response.status/100==3 and response.getheader('location'):
        return unshorten_me(response.getheader('location'))
    else:
        return url

#print unshorten_me('http://bit.ly/1whCayD')
print unshorten_me('http://tuq.in/KxEp')<commit_msg>Added support for returning all the redirect URLs<commit_after>import httplib
import urlparse

def expandURL(url):
    urls = [url]
    return unshorten_me(url, urls)

def unshorten_me(url, url_list):
    parsed = urlparse.urlparse(url)
    h = httplib.HTTPConnection(parsed.netloc)
    h.request('HEAD', parsed.path)
    response = h.getresponse()
    if response.status/100==3 and response.getheader('location'):
        url_list.append(response.getheader('location'))
        return unshorten_me(response.getheader('location'), url_list)
    else:
        if url not in url_list:
            url_list.append(url)
        return url_list

#print unshorten_me('http://bit.ly/1whCayD')
#print unshorten_me('http://tuq.in/KxEp')
print expandURL('http://tuq.in/KxEp')
{'fraction_non_alphanumeric': 0.12864077669902912, 'fraction_numerical': 0.008090614886731391, 'mean_word_length': 3.967871485943775, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6447061', 'n_tokens_mistral': 423, 'n_tokens_neox': 421, 'n_words': 78}