![](/img/trans.png)
[英]EventSource's response has a MIME type (“text/html”) 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”。 中斷連接。為什么我在從javascript向servlet發送請求時遇到此問題?
您需要在發送之前設置郵件的標頭:
response.writeHead(200, {
'Content-Type': 'text/event-stream',
'Cache-Control': 'no-cache',
'Connection': 'keep-alive'
});
您可以按照本文獲取更多信息: https : //www.html5rocks.com/en/tutorials/eventsource/basics/
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.