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

Add support for multipart upload streaming

Close #684, #201
This commit is contained in:
Jakub Roztocil
2020-08-15 17:50:00 +02:00
parent d32c8cab12
commit 6cd934d1b8
10 changed files with 86 additions and 12 deletions

View File

@@ -11,14 +11,15 @@ from urllib.parse import urlparse, urlunparse
import requests
# noinspection PyPackageRequirements
import urllib3
from httpie import __version__
from httpie.cli.dicts import RequestHeadersDict
from httpie.plugins.registry import plugin_manager
from httpie.sessions import get_httpie_session
from httpie.ssl import AVAILABLE_SSL_VERSION_ARG_MAPPING, HTTPieHTTPSAdapter
from httpie.uploads import get_multipart_data
from httpie.utils import get_expired_cookies, repr_dict
urllib3.disable_warnings()
FORM_CONTENT_TYPE = 'application/x-www-form-urlencoded; charset=utf-8'
@@ -256,6 +257,7 @@ def make_request_kwargs(
Translate our `args` into `requests.Request` keyword arguments.
"""
files = args.files
# Serialize JSON data, if needed.
data = args.data
auto_json = data and not args.form
@@ -274,6 +276,10 @@ def make_request_kwargs(
headers.update(args.headers)
headers = finalize_headers(headers)
if args.form and files:
data, headers['Content-Type'] = get_multipart_data(data, files)
files = None
kwargs = {
'method': args.method.lower(),
'url': args.url,
@@ -281,7 +287,7 @@ def make_request_kwargs(
'data': data,
'auth': args.auth,
'params': args.params,
'files': args.files,
'files': files,
}
return kwargs