简体   繁体   English

如何使EventSource与任何Content-Type标头一起使用?

[英]How can I make EventSource work with any Content-Type header?

I have a server which sends data exactly in the format expected by the SSE client, but Chrome closes the connection immediately as it gets the Content-Type header with this message: EventSource's response has a MIME type ("text/plain") that is not "text/event-stream". Aborting the connection. 我有一个服务器,它以SSE客户端所期望的格式发送数据,但Chrome在收到带有此消息的Content-Type标头时立即关闭连接: EventSource's response has a MIME type ("text/plain") that is not "text/event-stream". Aborting the connection. EventSource's response has a MIME type ("text/plain") that is not "text/event-stream". Aborting the connection.

Is it possible to make EventSource work even if the server doesn't set the appropriate text/event-stream content type? 即使服务器没有设置适当的text/event-stream内容类型,是否可以使EventSource工作?

It is not possible, sorry. 抱歉,这是不可能的。 In fact a browser that did not would not be following the standard . 事实上,浏览器不会遵循标准

(I think the motivation for a new MIME type was that proxies could recognize it and treat it differently.) (我认为新MIME类型的动机是代理可以识别它并以不同方式对待它。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM