1
0
mirror of https://github.com/httpie/cli.git synced 2025-08-10 22:42:05 +02:00

Merge branch 'master' into feature/uploads2020

# Conflicts:
#	httpie/cli/argparser.py
#	httpie/uploads.py
This commit is contained in:
Jakub Roztocil
2020-09-25 14:46:19 +02:00
9 changed files with 94 additions and 49 deletions

View File

@@ -144,11 +144,12 @@ def max_headers(limit):
def compress_body(request: requests.PreparedRequest, always: bool):
deflater = zlib.compressobj()
body_bytes = (
request.body
if isinstance(request.body, bytes)
else request.body.encode()
)
if isinstance(request.body, str):
body_bytes = request.body.encode()
elif hasattr(request.body, 'read'):
body_bytes = request.body.read()
else:
body_bytes = request.body
deflated_data = deflater.compress(body_bytes)
deflated_data += deflater.flush()
is_economical = len(deflated_data) < len(body_bytes)
@@ -282,7 +283,7 @@ def make_request_kwargs(
headers.update(args.headers)
headers = finalize_headers(headers)
if args.form and (files or args.multipart):
if (args.form and files) or args.multipart:
data, headers['Content-Type'] = get_multipart_data_and_content_type(
data=data,
files=files,