More line wrapping
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by David Pursehouse · committed by David Pursehouse · parent 587a515 · Browse files · 2 files·+38 added−14 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Trailers
- Change-Id: I950c3da727fb97b58d96a872b0d2ed718cc60ba8
Diff stats
2 files+38 added−14 removed
- other:+38 added−14 removed
Provenance
- Commit
44e426e- Tree
b8be7da- Author
David Pursehouse <david.pursehouse@sonymobile.com>- Committer
David Pursehouse <david.pursehouse@sonymobile.com>- Parent
587a515
2 files changed+38 added−14 removed
modified:docs/user/advanced.rst+36 added-13 removed
35 unmodified lines36 # both 'x-test' and 'x-test2' are sent37 s.get('http://httpbin.org/headers', headers={'x-test2': 'true'})38 39 40-Any dictionaries that you pass to a request method will be merged with the session-level values that are set. The method-level parameters override session parameters.40+Any dictionaries that you pass to a request method will be merged with the41+session-level values that are set. The method-level parameters override session42+parameters.43 44 .. admonition:: Remove a Value From a Dict Parameter45 44- Sometimes you'll want to omit session-level keys from a dict parameter. To do this, you simply set that key's value to ``None`` in the method-level parameter. It will automatically be omitted.46+ Sometimes you'll want to omit session-level keys from a dict parameter. To47+ do this, you simply set that key's value to ``None`` in the method-level48+ parameter. It will automatically be omitted.49 46-All values that are contained within a session are directly available to you. See the :ref:`Session API Docs <sessionapi>` to learn more.50+All values that are contained within a session are directly available to you.51+See the :ref:`Session API Docs <sessionapi>` to learn more.52 53 Request and Response Objects54 ----------------------------55 98 unmodified lines154 155 SSL Cert Verification156 ---------------------157 153-Requests can verify SSL certificates for HTTPS requests, just like a web browser. To check a host's SSL certificate, you can use the ``verify`` argument::158+Requests can verify SSL certificates for HTTPS requests, just like a web browser.159+To check a host's SSL certificate, you can use the ``verify`` argument::160 161 >>> requests.get('https://kennethreitz.com', verify=True)162 requests.exceptions.SSLError: hostname 'kennethreitz.com' doesn't match either of '*.herokuapp.com', 'herokuapp.com'163 12 unmodified lines176 <Response [200]>177 178 By default, ``verify`` is set to True. Option ``verify`` only applies to host certs.179 174-You can also specify a local cert to use as client side certificate, as a single file (containing the private key and the certificate) or as a tuple of both file's path::180+You can also specify a local cert to use as client side certificate, as a single181+file (containing the private key and the certificate) or as a tuple of both182+file's path::183 184 >>> requests.get('https://kennethreitz.com', cert=('/path/server.crt', '/path/key'))185 <Response [200]>186 13 unmodified lines200 201 tarball_url = 'https://github.com/kennethreitz/requests/tarball/master'202 r = requests.get(tarball_url, stream=True)203 196-At this point only the response headers have been downloaded and the connection remains open, hence allowing us to make content retrieval conditional::204+At this point only the response headers have been downloaded and the connection205+remains open, hence allowing us to make content retrieval conditional::206 207 if int(r.headers['content-length']) < TOO_LONG:208 content = r.content209 ...210 202-You can further control the workflow by use of the :class:`Response.iter_content <requests.Response.iter_content>` and :class:`Response.iter_lines <requests.Response.iter_lines>` methods. Alternatively, you can read the undecoded body from the underlying urllib3 :class:`urllib3.HTTPResponse <urllib3.response.HTTPResponse>` at :class:`Response.raw <requests.Response.raw>`.211+You can further control the workflow by use of the :class:`Response.iter_content <requests.Response.iter_content>`212+and :class:`Response.iter_lines <requests.Response.iter_lines>` methods.213+Alternatively, you can read the undecoded body from the underlying214+urllib3 :class:`urllib3.HTTPResponse <urllib3.response.HTTPResponse>` at215+:class:`Response.raw <requests.Response.raw>`.216 217 If you set ``stream`` to ``True`` when making a request, Requests cannot218 release the connection back to the pool unless you consume all the data or call219 :class:`Response.close <requests.Response.close>`. This can lead to11 unmodified lines231 232 Keep-Alive233 ----------234 222-Excellent news — thanks to urllib3, keep-alive is 100% automatic within a session! Any requests that you make within a session will automatically reuse the appropriate connection!235+Excellent news — thanks to urllib3, keep-alive is 100% automatic within a session!236+Any requests that you make within a session will automatically reuse the appropriate237+connection!238 224-Note that connections are only released back to the pool for reuse once all body data has been read; be sure to either set ``stream`` to ``False`` or read the ``content`` property of the ``Response`` object.239+Note that connections are only released back to the pool for reuse once all body240+data has been read; be sure to either set ``stream`` to ``False`` or read the241+``content`` property of the ``Response`` object.242 243 244 Streaming Uploads245 -----------------246 230-Requests supports streaming uploads, which allow you to send large streams or files without reading them into memory. To stream and upload, simply provide a file-like object for your body::247+Requests supports streaming uploads, which allow you to send large streams or248+files without reading them into memory. To stream and upload, simply provide a249+file-like object for your body::250 251 with open('massive-body', 'rb') as f:252 requests.post('http://some.url/streamed', data=f)253 254 255 Chunk-Encoded Requests256 ----------------------257 239-Requests also supports Chunked transfer encoding for outgoing and incoming requests. To send a chunk-encoded request, simply provide a generator (or any iterator without a length) for your body::258+Requests also supports Chunked transfer encoding for outgoing and incoming requests.259+To send a chunk-encoded request, simply provide a generator (or any iterator without260+a length) for your body::261 262 263 def gen():264 yield 'hi'334 unmodified lines599 600 Link Headers601 ------------602 582-Many HTTP APIs feature Link headers. They make APIs more self describing and discoverable.603+Many HTTP APIs feature Link headers. They make APIs more self describing and604+discoverable.605 584-GitHub uses these for `pagination <http://developer.github.com/v3/#pagination>`_ in their API, for example::606+GitHub uses these for `pagination <http://developer.github.com/v3/#pagination>`_607+in their API, for example::608 609 >>> url = 'https://api.github.com/users/kennethreitz/repos?page=1&per_page=10'610 >>> r = requests.head(url=url)611 >>> r.headers['link']94 unmodified linesmodified:docs/user/quickstart.rst+2 added-1 removed
202 unmodified lines203 },204 ...205 }206 207-There are many times that you want to send data that is not form-encoded. If you pass in a ``string`` instead of a ``dict``, that data will be posted directly.207+There are many times that you want to send data that is not form-encoded. If208+you pass in a ``string`` instead of a ``dict``, that data will be posted directly.209 210 For example, the GitHub API v3 accepts JSON-Encoded POST/PATCH data::211 212 >>> import json233 unmodified lines