mirror of
https://github.com/httpie/cli.git
synced 2025-01-29 00:39:08 +01:00
Cleanup
This commit is contained in:
parent
67496162fa
commit
00de49f4c3
@ -12,7 +12,8 @@ from requests.compat import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
#noinspection PyUnresolvedReferences,PyCompatibility
|
||||||
from urllib.parse import urlsplit
|
from urllib.parse import urlsplit
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
#noinspection PyUnresolvedReferences,PyCompatibility
|
||||||
from urlparse import urlsplit
|
from urlparse import urlsplit
|
||||||
|
|
||||||
|
@ -241,7 +241,7 @@ class Download(object):
|
|||||||
msg=HTTPResponse(response),
|
msg=HTTPResponse(response),
|
||||||
with_headers=False,
|
with_headers=False,
|
||||||
with_body=True,
|
with_body=True,
|
||||||
on_body_chunk_downloaded=self._chunk_downloaded,
|
on_body_chunk_downloaded=self.chunk_downloaded,
|
||||||
chunk_size=1024 * 8
|
chunk_size=1024 * 8
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -273,7 +273,7 @@ class Download(object):
|
|||||||
and self.status.total_size != self.status.downloaded
|
and self.status.total_size != self.status.downloaded
|
||||||
)
|
)
|
||||||
|
|
||||||
def _chunk_downloaded(self, chunk):
|
def chunk_downloaded(self, chunk):
|
||||||
"""
|
"""
|
||||||
A download progress callback.
|
A download progress callback.
|
||||||
|
|
||||||
|
@ -109,6 +109,7 @@ class HTTPResponse(HTTPMessage):
|
|||||||
def iter_lines(self, chunk_size):
|
def iter_lines(self, chunk_size):
|
||||||
return ((line, b'\n') for line in self._orig.iter_lines(chunk_size))
|
return ((line, b'\n') for line in self._orig.iter_lines(chunk_size))
|
||||||
|
|
||||||
|
#noinspection PyProtectedMember
|
||||||
@property
|
@property
|
||||||
def headers(self):
|
def headers(self):
|
||||||
original = self._orig.raw._original_response
|
original = self._orig.raw._original_response
|
||||||
|
@ -23,6 +23,7 @@ import subprocess
|
|||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import json
|
import json
|
||||||
|
#noinspection PyCompatibility
|
||||||
import argparse
|
import argparse
|
||||||
import tempfile
|
import tempfile
|
||||||
import unittest
|
import unittest
|
||||||
@ -31,9 +32,11 @@ import time
|
|||||||
from requests.structures import CaseInsensitiveDict
|
from requests.structures import CaseInsensitiveDict
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
#noinspection PyCompatibility
|
||||||
from urllib.request import urlopen
|
from urllib.request import urlopen
|
||||||
except ImportError:
|
except ImportError:
|
||||||
# noinspection PyUnresolvedReferences
|
# noinspection PyUnresolvedReferences
|
||||||
|
#noinspection PyCompatibility
|
||||||
from urllib2 import urlopen
|
from urllib2 import urlopen
|
||||||
try:
|
try:
|
||||||
from unittest import skipIf, skip
|
from unittest import skipIf, skip
|
||||||
@ -1613,9 +1616,9 @@ class DownloadTest(BaseTestCase):
|
|||||||
headers={'Content-Length': 10}
|
headers={'Content-Length': 10}
|
||||||
))
|
))
|
||||||
time.sleep(1.1)
|
time.sleep(1.1)
|
||||||
download._chunk_downloaded(b'12345')
|
download.chunk_downloaded(b'12345')
|
||||||
time.sleep(1.1)
|
time.sleep(1.1)
|
||||||
download._chunk_downloaded(b'12345')
|
download.chunk_downloaded(b'12345')
|
||||||
download.finish()
|
download.finish()
|
||||||
self.assertFalse(download.interrupted)
|
self.assertFalse(download.interrupted)
|
||||||
|
|
||||||
@ -1623,7 +1626,7 @@ class DownloadTest(BaseTestCase):
|
|||||||
download = Download(output_file=open(os.devnull, 'w'))
|
download = Download(output_file=open(os.devnull, 'w'))
|
||||||
download.start(Response(url=httpbin('/')))
|
download.start(Response(url=httpbin('/')))
|
||||||
time.sleep(1.1)
|
time.sleep(1.1)
|
||||||
download._chunk_downloaded(b'12345')
|
download.chunk_downloaded(b'12345')
|
||||||
download.finish()
|
download.finish()
|
||||||
self.assertFalse(download.interrupted)
|
self.assertFalse(download.interrupted)
|
||||||
|
|
||||||
@ -1633,7 +1636,7 @@ class DownloadTest(BaseTestCase):
|
|||||||
url=httpbin('/'),
|
url=httpbin('/'),
|
||||||
headers={'Content-Length': 5}
|
headers={'Content-Length': 5}
|
||||||
))
|
))
|
||||||
download._chunk_downloaded(b'1234')
|
download.chunk_downloaded(b'1234')
|
||||||
download.finish()
|
download.finish()
|
||||||
self.assertTrue(download.interrupted)
|
self.assertTrue(download.interrupted)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user