We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 2caed7d commit 4c4a743Copy full SHA for 4c4a743
asyncio/test_http_client.py
@@ -0,0 +1,25 @@
1
+import asyncio
2
+
3
+@asyncio.coroutine
4
+def print_http_headers(url):
5
+ reader, writer = yield from asyncio.open_connection(url, 80)
6
+ print(reader, writer)
7
+ print("================")
8
+ query = "GET / HTTP/1.0\r\n\r\n"
9
+ yield from writer.write(query.encode('latin-1'))
10
+ while True:
11
+ line = yield from reader.readline()
12
+ if not line:
13
+ break
14
+ if line:
15
+ print(line.rstrip())
16
17
+import logging
18
+logging.basicConfig(level=logging.INFO)
19
+url = "google.com"
20
+loop = asyncio.get_event_loop()
21
+#task = asyncio.async(print_http_headers(url))
22
+#loop.run_until_complete(task)
23
+loop.call_soon(print_http_headers(url))
24
+loop.run_forever()
25
+loop.close()
0 commit comments