Skip to content
Myr

improve advanced.rst

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

authored by Kenneth Reitz · committed by Kenneth Reitz · parent bf8c831 · Browse files · 1 file+8 added−7 removed
This commit

State

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

Diff stats

1 file+8 added−7 removed

  • other:+8 added−7 removed

1 file+8 added−7 removed

modified:docs/user/advanced.rst+8 added-7 removed
165 unmodified lines
166167 from requests import Request, Session168169 s = Session()170 req = Request('GET', url,171 data=data172 headers=headers173 )170 req = Request('GET', url, data=data, headers=headers)171172 prepped = s.prepare_request(req)173174 # do something with prepped.body175 prepped.body = 'Seriously, send exactly these bytes.'176177 # do something with prepped.headers178 prepped.headers['Keep-Dead'] = 'parrot'179180 resp = s.send(prepped,181 stream=stream,182 verify=verify,
178 unmodified lines
361upload image files to an HTML form with a multiple file field 'images'::362363 <input type="file" name="images" multiple="true" required="true"/>364365To do that, just set files to a list of tuples of ``(form_field_name, file_info)``:365To do that, just set files to a list of tuples of ``(form_field_name, file_info)``::366367 >>> url = 'http://httpbin.org/post'368 >>> multiple_files = [368 >>> multiple_files = [('images', ('foo.png', open('foo.png', 'rb'), 'image/png')),369 ('images', ('bar.png', open('bar.png', 'rb'), 'image/png'))]369 ('images', ('foo.png', open('foo.png', 'rb'), 'image/png')),370 ('images', ('bar.png', open('bar.png', 'rb'), 'image/png'))]371 >>> r = requests.post(url, files=multiple_files)372 >>> r.text373 {374 ...
543 unmodified lines