小编rsa*_*ris的帖子

Rails 流式传输不是流式传输

我正在努力向我的 rails 应用程序添加一个流组件,因为我想开始使用 SSE。我曾尝试在一个较小的示例中使用它,但仍然遇到问题。实际上,我一直无法让 Rails 正确地流式传输对 curl 请求的响应。我正在关注http://tenderlovemaking.com/2012/07/30/is-it-live.html 上的教程。我不确定是否需要为 OSX 配置某些东西,或者我的配置中是否缺少某些东西。任何帮助将不胜感激。

我在 OSX 上本地运行它。当我运行时,curl -i localhost:3000我得到以下响应:

HTTP/1.1 200 OK
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
X-Content-Type-Options: nosniff
X-UA-Compatible: chrome=1
Content-Type: text/event-stream
Last-Modified: Wed Apr 23 23:10:15 2014
Cache-Control: no-cache
Set-Cookie: request_method=GET; path=/
X-Request-Id: 89f2af3e-76e9-4873-85b0-3b6fe45f6343
X-Runtime: 0.001724
Transfer-Encoding: chunked

hello world
hello world
hello world
hello world
hello world
hello world
hello world
hello world
hello world
hello world
Run Code Online (Sandbox Code Playgroud)

问题是我一次得到了它,而不是像预期的那样得到一些响应。如果我需要提供更多信息,请告诉我

我的代码如下:

stream_test_controller.rb

class StreamTestController < ActionController::Base
  include ActionController::Live …
Run Code Online (Sandbox Code Playgroud)

ruby ruby-on-rails

6
推荐指数
1
解决办法
887
查看次数

标签 统计

ruby ×1

ruby-on-rails ×1