diff options
Diffstat (limited to 'lib/upr/json.rb')
-rw-r--r-- | lib/upr/json.rb | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/upr/json.rb b/lib/upr/json.rb index adcf47e..6c03b6b 100644 --- a/lib/upr/json.rb +++ b/lib/upr/json.rb @@ -4,6 +4,7 @@ begin rescue LoadError raise LoadError, "either json or json-pure is required" end +require 'rack' module Upr @@ -47,10 +48,12 @@ module Upr def rails_render_options env = upload_id self.upload_id = extract_upload_id(env) - { - :content_type => 'application/json', - :text => _once - } + text = if Rack::Request.new(env).GET.include?("long") + Proc.new { |response,output| each { |line| output.write(line) } } + else + _once + end + { :content_type => 'application/json', :text => text } end def _once |