Updated SSL socket test to use timeouts

This commit is contained in:
Nocturn9x 2023-04-22 12:55:38 +02:00
parent cfb91beb68
commit a48b4529cd
Signed by: nocturn9x
GPG Key ID: 8270F9F467971E59
1 changed files with 2 additions and 2 deletions

View File

@ -31,7 +31,7 @@ async def test(host: str, port: int, bufsize: int = 4096):
print(f"Attempting a connection to {host}:{port}") print(f"Attempting a connection to {host}:{port}")
await socket.connect((host, port)) await socket.connect((host, port))
print("Connected") print("Connected")
async with aiosched.with_context(): async with aiosched.with_context(timeout=5, silent=True) as ctx:
async with socket: async with socket:
# Closes the socket automatically # Closes the socket automatically
print("Entered socket context manager, sending request data") print("Entered socket context manager, sending request data")
@ -51,7 +51,7 @@ async def test(host: str, port: int, bufsize: int = 4096):
break break
if buffer: if buffer:
data = buffer.decode().split("\r\n") data = buffer.decode().split("\r\n")
print(f"HTTP Response below:") print(f"HTTP Response below {'(might be incomplete)' if ctx.timed_out else ''}:")
_print(f"Response: {data[0]}") _print(f"Response: {data[0]}")
_print("Headers:") _print("Headers:")
content = False content = False