]> granicus.if.org Git - python/commitdiff
bpo-35649: update http client example (GH-11441)
authorAshwin Ramaswami <aramaswamis@gmail.com>
Wed, 11 Sep 2019 12:41:54 +0000 (05:41 -0700)
committerJulien Palard <julien@palard.fr>
Wed, 11 Sep 2019 12:41:54 +0000 (14:41 +0200)
Doc/library/http.client.rst

index 4e761cd39a0109369a4f9de489569068a35a8001..48bc35ca76cc07b3be22703f4db9a2ab8b49a01f 100644 (file)
@@ -516,8 +516,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