Skip to content

Instantly share code, notes, and snippets.

@andriytyurnikov
Forked from josevalim/config.ru
Last active December 14, 2015 10:49

Revisions

  1. andriytyurnikov revised this gist Mar 3, 2013. 1 changed file with 6 additions and 4 deletions.
    10 changes: 6 additions & 4 deletions config.ru
    Original file line number Diff line number Diff line change
    @@ -1,14 +1,16 @@
    # rackup -s thin
    require 'thin'
    # rackup -s puma
    require 'puma' # thin does some weird caching

    run proc { |env|
    body = Enumerator.new do |socket|
    socket << " "*1024 # Browsers wait for time or big data chunk

    5.times do
    socket << "Hello"
    puts "Hello"
    sleep 1
    end
    end

    [200, { 'Content-Type' => 'text/html', "Content-Encoding" => "chunked" }, body]
    # if Content-Type is text/html, html parser may delay rendering of text
    [200, { "Content-Encoding" => "chunked" }, body]
    }
  2. @josevalim josevalim created this gist Mar 3, 2013.
    14 changes: 14 additions & 0 deletions config.ru
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@
    # rackup -s thin
    require 'thin'

    run proc { |env|
    body = Enumerator.new do |socket|
    5.times do
    socket << "Hello"
    puts "Hello"
    sleep 1
    end
    end

    [200, { 'Content-Type' => 'text/html', "Content-Encoding" => "chunked" }, body]
    }