Skip to content
Myr

Merge pull request #3069 from achermes/master

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Update docstring and API doc to document ability to add per-file headers in multipart POST

authored by Cory Benfield · committed by Cory Benfield · parents 3acf3a7, b8a5770 · Browse files · 2 files+8 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+8 added−2 removed

  • other:+8 added−2 removed

2 files+8 added−2 removed

modified:requests/api.py+5 added-1 removed
22 unmodified lines
23 :param data: (optional) Dictionary, bytes, or file-like object to send in the body of the :class:`Request`.24 :param json: (optional) json data to send in the body of the :class:`Request`.25 :param headers: (optional) Dictionary of HTTP Headers to send with the :class:`Request`.26 :param cookies: (optional) Dict or CookieJar object to send with the :class:`Request`.27 :param files: (optional) Dictionary of ``'name': file-like-objects`` (or ``{'name': ('filename', fileobj)}``) for multipart encoding upload.27 :param files: (optional) Dictionary of ``'name': file-like-objects`` (or ``{'name': file-tuple}``) for multipart encoding upload.28 ``file-tuple`` can be a 2-tuple ``('filename', fileobj)``, 3-tuple ``('filename', fileobj, 'content_type')``29 or a 4-tuple ``('filename', fileobj, 'content_type', custom_headers)``, where ``'content-type'`` is a string30 defining the content type of the given file and ``custom_headers`` a dict-like object containing additional headers31 to add for the file.32 :param auth: (optional) Auth tuple to enable Basic/Digest/Custom HTTP Auth.33 :param timeout: (optional) How long to wait for the server to send data34 before giving up, as a float, or a :ref:`(connect timeout, read35 timeout) <timeouts>` tuple.
114 unmodified lines
modified:requests/models.py+3 added-1 removed
101 unmodified lines
102 def _encode_files(files, data):103 """Build the body for a multipart/form-data request.104105 Will successfully encode files when passed as a dict or a list of106 2-tuples. Order is retained if data is a list of 2-tuples but arbitrary106 tuples. Order is retained if data is a list of tuples but arbitrary107 if parameters are supplied as a dict.108 The tuples may be 2-tuples (filename, fileobj), 3-tuples (filename, fileobj, contentype)109 or 4-tuples (filename, fileobj, contentype, custom_headers).110111 """112 if (not files):113 raise ValueError("Files must be provided.")
740 unmodified lines