From 107af1d7f25ed233aec6a85509ae177205d45c4c Mon Sep 17 00:00:00 2001 From: nocturn9x Date: Sat, 9 Oct 2021 14:14:33 +0200 Subject: [PATCH] Added https test --- .gitignore | 1 + tests/https.py | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 tests/https.py diff --git a/.gitignore b/.gitignore index a3201ab..fef2fe8 100644 --- a/.gitignore +++ b/.gitignore @@ -138,3 +138,4 @@ dmypy.json .idea/misc.xml .idea/modules.xml .idea/vcs.xml + diff --git a/tests/https.py b/tests/https.py new file mode 100644 index 0000000..3dcd5de --- /dev/null +++ b/tests/https.py @@ -0,0 +1,25 @@ +import giambio +import socket as sock +import ssl + + +async def test(host: str, port: int): + socket = giambio.socket.wrap_socket(ssl.wrap_socket(sock.socket())) + await socket.connect((host, port)) + async with socket: + await socket.send_all(b"""GET / HTTP/1.1\r + Host: google.com\r + User-Agent: owo\r + Accept: text/html\r + Connection: keep-alive\r\n\r\n""") + buffer = b"" + while True: + data = await socket.receive(4096) + if data: + buffer += data + else: + break + print("\n".join(buffer.decode().split("\r\n"))) + + +giambio.run(test, "google.com", 443)