服务器代码:
import http.server
import socketserver
PORT = 8000
Handler = http.server.SimpleHTTPRequestHandler
with socketserver.TCPServer(("", PORT), Handler) as httpd:
print("serving at port", PORT)
httpd.serve_forever()
客户代码:
import http.client
conn = http.client.HTTPSConnection("localhost", 8000)
conn.request("HEAD","/index.html")
我得到了ssl.SSLError:[SSL:UNKNOWN_PROTOCOL]未知协议(_ssl.c:777) 客户端错误,代码400,消息服务器端错误请求版本。我不知道它有什么问题。