]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Mention `curl` in `contextvars` docs (#123838)
authorsobolevn <mail@sobolevn.me>
Mon, 9 Sep 2024 13:58:49 +0000 (16:58 +0300)
committerGitHub <noreply@github.com>
Mon, 9 Sep 2024 13:58:49 +0000 (16:58 +0300)
Doc/library/contextvars.rst

index b2261ea5127e619aea725615ab67900a6594ad3e..2a79dfe8f81e26eb5a47599c25902fc7f5354b3a 100644 (file)
@@ -254,7 +254,7 @@ client::
         # without passing it explicitly to this function.
 
         client_addr = client_addr_var.get()
-        return f'Good bye, client @ {client_addr}\n'.encode()
+        return f'Good bye, client @ {client_addr}\r\n'.encode()
 
     async def handle_request(reader, writer):
         addr = writer.transport.get_extra_info('socket').getpeername()
@@ -268,9 +268,10 @@ client::
             print(line)
             if not line.strip():
                 break
-            writer.write(line)
 
-        writer.write(render_goodbye())
+        writer.write(b'HTTP/1.1 200 OK\r\n')  # status line
+        writer.write(b'\r\n')  # headers
+        writer.write(render_goodbye())  # body
         writer.close()
 
     async def main():
@@ -282,5 +283,6 @@ client::
 
     asyncio.run(main())
 
-    # To test it you can use telnet:
+    # To test it you can use telnet or curl:
     #     telnet 127.0.0.1 8081
+    #     curl 127.0.0.1:8081