Sha256: 23b43d23d67ac853c13c319b494db20da10ef4896f7a4c40e49f8f8c55b6d235

Contents?: true

Size: 887 Bytes

Versions: 131

Compression:

Stored size: 887 Bytes

Contents

require 'socket'
require 'stringio'

def do_test(st, chunk)
  s = TCPSocket.new('127.0.0.1',ARGV[0].to_i);
  req = StringIO.new(st)
  nout = 0
  randstop = rand(st.length / 10)
  STDERR.puts "stopping after: #{randstop}"

  begin
    while data = req.read(chunk)
      nout += s.write(data)
      s.flush
      sleep 0.1
      if nout > randstop
        STDERR.puts "BANG! after #{nout} bytes."
        break
      end
    end
  rescue Object => e
    STDERR.puts "ERROR: #{e}"
  ensure
    s.close
  end
end

content = "-" * (1024 * 240)
st = "GET / HTTP/1.1\r\nHost: www.zedshaw.com\r\nContent-Type: text/plain\r\nContent-Length: #{content.length}\r\n\r\n#{content}"

puts "length: #{content.length}"

threads = []
ARGV[1].to_i.times do
  t = Thread.new do
    size = 100
    puts ">>>> #{size} sized chunks"
    do_test(st, size)
  end

  threads << t
end

threads.each {|t|  t.join}

Version data entries

131 entries across 128 versions & 8 rubygems

Version Path
puma-6.5.0-java tools/trickletest.rb
puma-6.5.0 tools/trickletest.rb
jun-puma-1.0.1-java tools/trickletest.rb
jun-puma-1.0.0-java tools/trickletest.rb
puma-5.6.9-java tools/trickletest.rb
puma-6.4.3-java tools/trickletest.rb
puma-6.4.3 tools/trickletest.rb
puma-5.6.9 tools/trickletest.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/puma-5.6.8/tools/trickletest.rb
tinymce-rails-7.1.2 vendor/bundle/ruby/3.3.0/gems/puma-6.4.2/tools/trickletest.rb
puma-5.6.8-java tools/trickletest.rb
puma-5.6.8 tools/trickletest.rb
puma-6.4.2-java tools/trickletest.rb
puma-6.4.2 tools/trickletest.rb
puma-6.4.1-java tools/trickletest.rb
puma-6.4.1 tools/trickletest.rb
puma-6.4.0-java tools/trickletest.rb
puma-6.4.0 tools/trickletest.rb
puma-5.6.7-java tools/trickletest.rb
puma-5.6.7 tools/trickletest.rb