Http request header Detailed

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

We use a look python demo package body length in response to the enlarged portion 10 actually is the length specified length 11

import socket

sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
serverAddress = ("127.0.0.1", 12345)
sock.bind(serverAddress)
sock.listen(100)

while True:
    conn, client_add = sock.accept()
    try:
        data = conn.recv(4096)
        response = "HTTP/1.1 200 OK\r\nContent-Length: 10\r\n\r\nhello world"
        conn.send(response.encode())
    finally:
        conn.close()

 

By subcontracting 10 also found that the length of the content-length header will represent a very important parameter 

 

Guess you like

Origin www.cnblogs.com/jackey2015/p/11566891.html