Created
December 28, 2023 16:26
-
-
Save NicolaiSoeborg/a75e2a474c315ac1cb2e79de1f594d8c to your computer and use it in GitHub Desktop.
nc/socat like raw socket access to HTTPS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import trio | |
DOMAIN = "example.com" | |
PATH = "/" | |
async def main(): | |
s0 = await trio.open_ssl_over_tcp_stream(DOMAIN, 443, https_compatible=True) | |
# Request a connection to the website | |
await s0.send_all(f"GET {PATH} HTTP/1.1\r\nHost: {DOMAIN}\r\n\r\n".encode()) | |
async for chunk in s0: | |
print(f"=> {chunk}") | |
if __name__ == '__main__': | |
trio.run(main) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment