use*_*208 2 python curl google-chrome
我们有一个通过 Python 提供服务的内部 Web 服务器,它一直在端口 8080 上运行,直到本周末才出现问题。本周末 Chrome 更新后,当我们尝试通过 Chrome 访问网络服务器时,我和我的同事现在收到 ERR_INVALID_HTTP_RESPONSE。这个问题似乎是 Chrome 和 8080 端口特有的。8080 端口在 IE 中有效,80 端口对 IE 和 Chrome 都有效,服务器端没有任何变化。Web 服务器不在端口 80 上提供服务,因为它仍在开发中而不是生产中(这是公司内部服务的标准做法)。
根据一些研究,随着 Chrome 的更新,似乎不同的网站/服务都曾出现过这个问题。这些帖子中的大多数似乎都涉及将 HTTP/0.9 归入 bad-security-equals-no-support 桶。我们的服务器使用 HTTP/1.0,我也尝试过 HTTP/1.1,看看我们是否有类似的问题。
[<blah>]$ curl --head http://<domain>
HTTP/1.0 200 OK
Server: BaseHTTP/0.3 Python/2.6.6
Date: Mon, 17 Apr 2017 21:53:57 GMT
Content-type: text/html
[<blah>]$ curl --head http://<domain>:8080
HTTP/1.0 200 OK
Server: BaseHTTP/0.3 Python/2.7.13
Date: Mon, 17 Apr 2017 21:54:04 GMT
Content-type: text/html
# after setting handler.protocol_version = 'HTTP/1.1'
[<blah>]$ curl --head http://<domain>:8080
HTTP/1.1 200 OK
Server: BaseHTTP/0.3 Python/2.7.13
Date: Mon, 17 Apr 2017 21:54:57 GMT
Content-type: text/html
Run Code Online (Sandbox Code Playgroud)
curl 没有显示任何明显的标题问题(我可以看到)来表明可能的根本原因。Chrome 的开发者控制台也没有提供任何答案。显然,我错过了一些微妙的东西,因为浏览器更新似乎不应该完全阻止访问服务器。
小智 5
尝试像这样格式化您的发送数据
connection.sendall(b'HTTP/1.0 200 OK\r\nContent-Length: 11\r\nContent-Type: text/html; charset=UTF-8\r\n\r\nHello World\r\n')
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5153 次 |
| 最近记录: |