我想从龙卷风服务器发送gzip压缩数据到javascript客户端。这是我的代码。我可以通过Python中的龙卷风websocket发送gzip压缩数据吗?
buf = StringIO()
gfile = gzip.GzipFile(mode='wb', fileobj=buf)
try:
gfile.write("hello world")
finally:
gfile.close()
compressed_data = buf.getvalue()
self.write_message(compressed_data)
服务器端不提供错误。但是chrome会产生一个错误“无法将文本框架解码为UTF8”。
这里有什么解决方法吗?
您设置了哪些标头? –
我也尝试设置标题,但Websockets是否需要标题? 这是我在搜索时发现的链接。 [链接](https://stackoverflow.com/questions/17082166/how-to-send-json-header-via-python-tornado-in-a-websocket) –
我想你的客户期望使用一个子协议UTF-8。 –