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