Python | Http request headers

HTTP request header


In the previous section, we mainly talked about the response header. We did not pay attention to what is in the request header. Run the following code:

import socket

server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server_socket.bind(('192.168.31.199', 8090))
server_socket.listen(128)
while True:
client_socket, client_addr = server_socket.accept()
data = client_socket.recv(1024).decode('utf8')
print('Data received from {}{}'.format(client_addr[0], data))


client_socket.send('HTTP/1.1 200 OK '.encode('utf8'))
client_socket.send('content-type:text/html '.encode('utf8'))
client_socket.send(' '.encode('utf8'))

client_socket.send('

hello world

'.encode('utf8'))

Related Articles

Explore More Special Offers

  1. Short Message Service(SMS) & Mail Service

    50,000 email package starts as low as USD 1.99, 120 short messages start at only USD 1.00