[downloader:http] remove 'pyopenssl' import (#5156)
This commit is contained in:
@@ -13,12 +13,7 @@ import mimetypes
|
|||||||
from requests.exceptions import RequestException, ConnectionError, Timeout
|
from requests.exceptions import RequestException, ConnectionError, Timeout
|
||||||
from .common import DownloaderBase
|
from .common import DownloaderBase
|
||||||
from .. import text, util
|
from .. import text, util
|
||||||
|
|
||||||
from ssl import SSLError
|
from ssl import SSLError
|
||||||
try:
|
|
||||||
from OpenSSL.SSL import Error as OpenSSLError
|
|
||||||
except ImportError:
|
|
||||||
OpenSSLError = SSLError
|
|
||||||
|
|
||||||
|
|
||||||
class HttpDownloader(DownloaderBase):
|
class HttpDownloader(DownloaderBase):
|
||||||
@@ -249,7 +244,7 @@ class HttpDownloader(DownloaderBase):
|
|||||||
file_header = next(
|
file_header = next(
|
||||||
content if response.raw.chunked
|
content if response.raw.chunked
|
||||||
else response.iter_content(16), b"")
|
else response.iter_content(16), b"")
|
||||||
except (RequestException, SSLError, OpenSSLError) as exc:
|
except (RequestException, SSLError) as exc:
|
||||||
msg = str(exc)
|
msg = str(exc)
|
||||||
print()
|
print()
|
||||||
continue
|
continue
|
||||||
@@ -283,7 +278,7 @@ class HttpDownloader(DownloaderBase):
|
|||||||
self.out.start(pathfmt.path)
|
self.out.start(pathfmt.path)
|
||||||
try:
|
try:
|
||||||
self.receive(fp, content, size, offset)
|
self.receive(fp, content, size, offset)
|
||||||
except (RequestException, SSLError, OpenSSLError) as exc:
|
except (RequestException, SSLError) as exc:
|
||||||
msg = str(exc)
|
msg = str(exc)
|
||||||
print()
|
print()
|
||||||
continue
|
continue
|
||||||
@@ -310,7 +305,7 @@ class HttpDownloader(DownloaderBase):
|
|||||||
try:
|
try:
|
||||||
for _ in response.iter_content(self.chunk_size):
|
for _ in response.iter_content(self.chunk_size):
|
||||||
pass
|
pass
|
||||||
except (RequestException, SSLError, OpenSSLError) as exc:
|
except (RequestException, SSLError) as exc:
|
||||||
print()
|
print()
|
||||||
self.log.debug(
|
self.log.debug(
|
||||||
"Unable to consume response body (%s: %s); "
|
"Unable to consume response body (%s: %s); "
|
||||||
|
|||||||
Reference in New Issue
Block a user