bpo-35649: update http client example (GH-11441) (GH-15930)
(cherry picked from commit 62cf6981425c6a6b136c5e2abef853364f535e9d)
Co-authored-by: Ashwin Ramaswami <aramaswamis@gmail.com>
diff --git a/Doc/library/http.client.rst b/Doc/library/http.client.rst
index 4e761cd..48bc35c 100644
--- a/Doc/library/http.client.rst
+++ b/Doc/library/http.client.rst
@@ -516,8 +516,11 @@
>>> # 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