Catch bad status line

This commit is contained in:
Julien Duponchelle 2015-11-11 10:48:38 +01:00
parent c40effa607
commit 1b78cf0134

View File

@ -21,6 +21,7 @@ import sys
import socket import socket
import time import time
import urllib.request import urllib.request
import http.client
from multiprocessing import Pool from multiprocessing import Pool
class CheckError(Exception): class CheckError(Exception):
@ -56,6 +57,8 @@ def check_url(args):
else: else:
# We allow error code like 302 # We allow error code like 302
return return
except http.client.BadStatusLine as err:
error = CheckError('Bad status line {} ({})'.format(url, str(err)))
except urllib.error.URLError as err: except urllib.error.URLError as err:
error = CheckError('Invalid URL {} ({})'.format(url, str(err))) error = CheckError('Invalid URL {} ({})'.format(url, str(err)))
except socket.timeout as err: except socket.timeout as err: