mirror of
https://github.com/puma/puma.git
synced 2022-11-09 13:48:40 -05:00
don't use #close_write anymore
git-svn-id: svn+ssh://rubyforge.org/var/svn/mongrel/trunk@708 19e92222-5c0b-0410-8929-a290d50e31e9
This commit is contained in:
parent
d665da08ba
commit
638620f70d
2 changed files with 13 additions and 17 deletions
|
@ -1,10 +1,8 @@
|
|||
|
||||
# Minimal test to help debug JRuby socket issues
|
||||
|
||||
require 'mongrel'
|
||||
|
||||
include Mongrel
|
||||
|
||||
@server = HttpServer.new("127.0.0.1", 9997, num_processors=1)
|
||||
@server.run
|
||||
@server.stop(true)
|
||||
require 'socket'
|
||||
socket = TCPSocket.new('127.0.0.1', '3000')
|
||||
socket.write("G")
|
||||
socket.close_write
|
||||
socket.write("E")
|
||||
|
|
|
@ -33,8 +33,10 @@ class WebServerTest < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
def teardown
|
||||
redirect_test_io do
|
||||
@server.stop(true)
|
||||
end
|
||||
end
|
||||
|
||||
def test_simple_server
|
||||
hit(['http://localhost:9998/test'])
|
||||
|
@ -43,24 +45,20 @@ class WebServerTest < Test::Unit::TestCase
|
|||
|
||||
|
||||
def do_test(string, chunk, close_after=nil)
|
||||
socket = TCPSocket.new("127.0.0.1", 9998);
|
||||
@socket = TCPSocket.new("127.0.0.1", 9998);
|
||||
request = StringIO.new(string)
|
||||
chunks_out = 0
|
||||
|
||||
while data = request.read(chunk)
|
||||
chunks_out += socket.write(data)
|
||||
puts "Chunks: #{chunks_out.inspect}"
|
||||
socket.flush
|
||||
chunks_out += @socket.write(data)
|
||||
@socket.flush
|
||||
sleep 0.2
|
||||
if close_after and chunks_out > close_after
|
||||
puts "** Closing write"
|
||||
socket.close_write
|
||||
@socket.close
|
||||
sleep 1
|
||||
end
|
||||
end
|
||||
socket.write(" ") if RUBY_PLATFORM =~ /mingw|mswin|cygwin/
|
||||
socket.close
|
||||
puts "** Closing entire socket"
|
||||
@socket.write(" ") # Some platforms only raise the exception on attempted write
|
||||
end
|
||||
|
||||
def test_trickle_attack
|
||||
|
|
Loading…
Reference in a new issue