Skip to content

Instantly share code, notes, and snippets.

@rdeioris
Created February 28, 2020 16:17
Show Gist options
  • Save rdeioris/dc05e63c2f61bfd757bd9270bc651a05 to your computer and use it in GitHub Desktop.
Save rdeioris/dc05e63c2f61bfd757bd9270bc651a05 to your computer and use it in GitHub Desktop.
import socket
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
#s.connect(('towel.blinkenlights.nl', 23))
s.connect(('aiv01.it', 80))
first_line = 'GET /corsi/programmazione HTTP/1.0\r\n'
first_header = 'Host: aiv01.it\r\n'
second_header = 'Connection: close\r\n'
third_header = 'Foo: Bar\r\n'
empty_line = '\r\n'
s.send((first_line+first_header+second_header +
third_header+empty_line).encode('ascii'))
while True:
data = s.recv(4096)
if not data:
break
print(data,)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment