http_request = ‘GET / HTTP/1.1\r\nhost:{}\r\n\r\n‘.format(host)
注意下格式就可以了
响应的格式
HTTP/1.1 301 Moved Permanently ???????Date: Sun, 05 Jun 2016 12:37:55 GMT ???????Content-Type: text/html ???????Content-Length: 178 ???????Connection: keep-alive ???????Keep-Alive: timeout=30 ???????Location: https://movie.douban.com/top250 ???????Server: dae ???????X-Content-Type-Options: nosniff ???????<html> ???????<head><title>301 Moved Permanently</title></head> ???????<body bgcolor="white"> ???????<center><h1>301 Moved Permanently</h1></center> ???????<hr><center>nginx</center> ???????</body> ???????</html>
\r\n\r\n 分割的是HTTP协议的Header和Body部分
HTTP协议
原文地址:https://www.cnblogs.com/owenqing/p/10207891.html