我正在使用带有 python 的 BaseHttp 运行服务器。
我收到来自基于 HTTP/1.1 的客户端的请求
但是,当我用我的回复回复客户时,客户拒绝接受我的回复。经过进一步分析,我发现我发送的 HTTP 版本是 HTTP/1.0。但是,我不知道它是如何设置的。
客户端的错误是。
Original message: not well-formed (invalid token): line 2, column 4
Response
HTTP/1.0 200 OK
Server: BaseHTTP/0.3 Python/2.7.5
Date: Wed, 30 Jul 2014 15:11:42 GMT
Content-type: application/soap+xml; charset=utf-8
Content-length: 823
我通过以下方式设置标题:
self.send_response(200)
self.send_header("Content-type", "application/soap+xml; charset=utf-8")
self.send_header("Content-length", content_length)
self.end_headers()