]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-35649: update http client example (GH-11441) (GH-15931)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Wed, 11 Sep 2019 13:13:55 +0000 (06:13 -0700)
committerJulien Palard <julien@palard.fr>
Wed, 11 Sep 2019 13:13:55 +0000 (15:13 +0200)
(cherry picked from commit 62cf6981425c6a6b136c5e2abef853364f535e9d)

Co-authored-by: Ashwin Ramaswami <aramaswamis@gmail.com>
Doc/library/http.client.rst

index 3ebeb10aee9a97d31ebfe30718521d143bf1451c..bc73c7a9bdf77b72408cea4ba99889b6b7a3543a 100644 (file)
@@ -497,8 +497,11 @@ Here is an example session that uses the ``GET`` method::
    >>> # The following example demonstrates reading data in chunks.
    >>> conn.request("GET", "/")
    >>> r1 = conn.getresponse()
-   >>> while not r1.closed:
-   ...     print(r1.read(200))  # 200 bytes
+   >>> while True:
+   ...     chunk = r1.read(200)  # 200 bytes
+   ...     if not chunk:
+   ...          break
+   ...     print(repr(chunk))
    b'<!doctype html>\n<!--[if"...
    ...
    >>> # Example of an invalid request