Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def fetch(request, timeout=None):
urlopen_params = {}
if timeout:
urlopen_params['timeout'] = timeout
resp = urlopen(request, **urlopen_params)
if resp.code < 200 or resp.code >= 300:
return False
# by RFC, default HTTP charset is ISO-8859-1
charset = get_charset(resp) or 'iso-8859-1'
content = resp.read().decode(charset)
resp.close()
return content