I’m working on a simple project involving sockets. Kinda like telnet. I just want it to connect to port 80 and execute GET /
Here is what I’m trying:
import socket
size = 100000
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
host = "localhost"
port = 80
s.connect((host, port))
stuff = "GET /"
s.send(stuff)
r = s.recv(size)
print(r)
I run it, it connects but I don't get the output of GET /
The HTTP spec says that you need two newlines (
'\r\n' * 2) after the header. Try: