Error[8]: Undefined offset: 2, File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 121
File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 473, decode(

概述我正忙着尝试使用Sinatra和Rack进行这种简单的流测试. 在我的stream.rb文件中,我有: require 'sinatra'require 'sinatra/streaming'class StreamAPI < Sinatra::Base helpers Sinatra::Streaming get '/stream' do stream do 我正忙着尝试使用Sinatra和Rack进行这种简单的流测试.

在我的stream.rb文件中,我有:

require 'sinatra'require 'sinatra/streaming'class StreamAPI < Sinatra::Base    helpers Sinatra::Streaming    get '/stream' do        stream do |out|            5.times do                out.puts "Hello!"                sleep 1            end            out.flush        end    end    run! if app_file == 
require 'rack'require './stream.rb'run StreamAPI
end

在我的config.ru我有:

[+++]

当我卷曲网址时,我得到“你好!” 5次,但5秒后一次全部.查看标题我可以看到transfer-encoding设置为Chunked.我想要的是“你好!”在暂停1秒之后再通过另一个.

编辑:除了下面选择的答案,我还需要关闭proxy_buffering;到我的Nginx配置文件.

解决方法 这取决于您使用的服务器.从 Sinatra README:

Note that the streaming behavior,especially the number of concurrent requests,highly depends on the web server used to serve the application. Some servers,like WEBRick,might not even support streaming at all. If the server does not support streaming,the body will be sent all at once after the block passed to stream finishes executing.

看起来您正在使用不支持流式传输的服务器.如果你切换到一个(例如Thin或Puma)这应该工作.

总结

以上是内存溢出为你收集整理的ruby – Sinatra :: Streaming with Rack没有分块响应全部内容,希望文章能够帮你解决ruby – Sinatra :: Streaming with Rack没有分块响应所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

)
File: /www/wwwroot/outofmemory.cn/tmp/route_read.php, Line: 126, InsideLink()
File: /www/wwwroot/outofmemory.cn/tmp/index.inc.php, Line: 166, include(/www/wwwroot/outofmemory.cn/tmp/route_read.php)
File: /www/wwwroot/outofmemory.cn/index.php, Line: 30, include(/www/wwwroot/outofmemory.cn/tmp/index.inc.php)
ruby – Sinatra :: Streaming with Rack没有分块响应_语言综合_内存溢出

ruby – Sinatra :: Streaming with Rack没有分块响应

ruby – Sinatra :: Streaming with Rack没有分块响应,第1张

概述我正忙着尝试使用Sinatra和Rack进行这种简单的流测试. 在我的stream.rb文件中,我有: require 'sinatra'require 'sinatra/streaming'class StreamAPI < Sinatra::Base helpers Sinatra::Streaming get '/stream' do stream do 我正忙着尝试使用Sinatra和Rack进行这种简单的流测试.

在我的stream.rb文件中,我有:

require 'sinatra'require 'sinatra/streaming'class StreamAPI < Sinatra::Base    helpers Sinatra::Streaming    get '/stream' do        stream do |out|            5.times do                out.puts "Hello!"                sleep 1            end            out.flush        end    end    run! if app_file == 
require 'rack'require './stream.rb'run StreamAPI
end

在我的config.ru我有:

当我卷曲网址时,我得到“你好!” 5次,但5秒后一次全部.查看标题我可以看到transfer-encoding设置为Chunked.我想要的是“你好!”在暂停1秒之后再通过另一个.

编辑:除了下面选择的答案,我还需要关闭proxy_buffering;到我的Nginx配置文件.

解决方法 这取决于您使用的服务器.从 Sinatra README:

Note that the streaming behavior,especially the number of concurrent requests,highly depends on the web server used to serve the application. Some servers,like WEBRick,might not even support streaming at all. If the server does not support streaming,the body will be sent all at once after the block passed to stream finishes executing.

看起来您正在使用不支持流式传输的服务器.如果你切换到一个(例如Thin或Puma)这应该工作.

总结

以上是内存溢出为你收集整理的ruby – Sinatra :: Streaming with Rack没有分块响应全部内容,希望文章能够帮你解决ruby – Sinatra :: Streaming with Rack没有分块响应所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/1276601.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-09
下一篇 2022-06-09

发表评论

登录后才能评论

评论列表(0条)

保存