Added https test

This commit is contained in:
nocturn9x 2021-10-09 14:14:33 +02:00
parent 0f5bc18069
commit 107af1d7f2
2 changed files with 26 additions and 0 deletions

1
.gitignore vendored
View File

@ -138,3 +138,4 @@ dmypy.json
.idea/misc.xml
.idea/modules.xml
.idea/vcs.xml

25
tests/https.py Normal file
View File

@ -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)