简体   繁体   English

EventSource的响应具有MIME类型(“text / plain”),而不是“text / event-stream”

[英]EventSource's response has a MIME type (“text/plain”) that is not “text/event-stream”

EventSource's response has a MIME type ("text/plain") that is not "text/event-stream". EventSource的响应具有MIME类型(“text / plain”),而不是“text / event-stream”。 Aborting the connection.Why I'm getting this problem when sending a request from javascript to servlet? 中断连接。为什么我在从javascript向servlet发送请求时遇到此问题?

You need to set the header of the message before sending it: 您需要在发送之前设置邮件的标头:

  response.writeHead(200, {
    'Content-Type': 'text/event-stream',
    'Cache-Control': 'no-cache',
    'Connection': 'keep-alive'
  });

You can follow this article for more information: https://www.html5rocks.com/en/tutorials/eventsource/basics/ 您可以按照本文获取更多信息: https//www.html5rocks.com/en/tutorials/eventsource/basics/

暂无
暂无

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

相关问题 EventSource的响应具有不是“ text / event-stream”的MIME类型(“ text / html”) - EventSource's response has a MIME type (“text/html”) that is not “text/event-stream” EventSource 的响应具有不是“text/event-stream”的 MIME 类型(“text/html”)。 中止连接。 标头设置为文本/事件流 - EventSource's response has a MIME type ("text/html") that is not "text/event-stream". Aborting the connection. header is set to text/event-stream 服务器发送的事件不是“文本/事件流” - Server Sent Events are not “text/event-stream” 有没有办法在不使用事件侦听器的情况下从文本/事件流中获得单个响应? - Is there a way to get a single response from a text/event-stream without using event listeners? Express NodeJS 路由错误文本/html 不是文本/事件流 - Express NodeJS Routing Error text/html is not text/event-stream 是否可以在 WebBrowser 中使用 JavaScript 使用文本/事件流? - Is it possible to consume text/event-stream with JavaScript in a WebBrowser? 当服务器永不停止加载时,如何在 JavaScript 中存储来自 get 请求的初始文本/事件流响应? - How can I store the initial text/event-stream response from a get request in JavaScript when the server never stops loading? 请求具有文本/纯MIME类型的JSONP - Request JSONP with text/plain MIME Type 如何从express.js发送“文本/事件流”数据? - How to send 'text/event-stream' data from express.js? 资源解释为脚本,但使用MIME类型text / plain传输 - 用于本地文件 - Resource interpreted as Script but transferred with MIME type text/plain - for local file
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM