http版本中的响应bashttp模块python
-
21-12-2019 - |
题
我正在使用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()
. 解决方案
设置 protocol_version
属性在您的处理程序类上:
handler.protocol_version = 'HTTP/1.1'
.
这要求您设置了一个您已经执行的Content-Length
标题。
不隶属于 StackOverflow