eventmachine-win32 0.5.3 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- data/RELEASE_NOTES +14 -1
- data/TODO +10 -0
- data/lib/em/deferrable.rb +89 -0
- data/lib/em/eventable.rb +50 -0
- data/lib/eventmachine.rb +274 -9
- data/lib/eventmachine_version.rb +42 -0
- data/lib/evma.rb +35 -0
- data/lib/evma/callback.rb +35 -0
- data/lib/evma/container.rb +77 -0
- data/lib/evma/factory.rb +80 -0
- data/lib/evma/protocol.rb +89 -0
- data/lib/evma/reactor.rb +50 -0
- data/lib/pr_eventmachine.rb +714 -0
- data/lib/protocols/header_and_content.rb +134 -0
- data/lib/protocols/httpclient.rb +233 -0
- data/lib/protocols/line_and_text.rb +141 -0
- data/lib/protocols/tcptest.rb +67 -0
- data/lib/rubyeventmachine.so +0 -0
- data/tests/test_basic.rb +106 -0
- data/tests/test_eventables.rb +85 -0
- data/tests/test_hc.rb +207 -0
- data/tests/test_httpclient.rb +94 -0
- data/tests/test_ltp.rb +192 -0
- data/tests/test_ud.rb +52 -0
- metadata +29 -3
@@ -0,0 +1,94 @@
|
|
1
|
+
# $Id: test_httpclient.rb 226 2006-08-10 08:55:49Z blackhedd $
|
2
|
+
#
|
3
|
+
# Author:: blackhedd (gmail address: garbagecat10).
|
4
|
+
# Date:: 8 Apr 2006
|
5
|
+
#
|
6
|
+
# Copyright (C) 2006 by Francis Cianfrocca. All Rights Reserved.
|
7
|
+
#
|
8
|
+
# This program is made available under the terms of the GPL version 2.
|
9
|
+
#
|
10
|
+
# See EventMachine and EventMachine::Connection for documentation and
|
11
|
+
# usage examples.
|
12
|
+
#
|
13
|
+
#----------------------------------------------------------------------------
|
14
|
+
#
|
15
|
+
# Copyright (C) 2006 by Francis Cianfrocca. All Rights Reserved.
|
16
|
+
#
|
17
|
+
# Gmail: garbagecat10
|
18
|
+
#
|
19
|
+
# This program is free software; you can redistribute it and/or modify
|
20
|
+
# it under the terms of the GNU General Public License as published by
|
21
|
+
# the Free Software Foundation; either version 2 of the License, or
|
22
|
+
# (at your option) any later version.
|
23
|
+
#
|
24
|
+
# This program is distributed in the hope that it will be useful,
|
25
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
26
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
27
|
+
# GNU General Public License for more details.
|
28
|
+
#
|
29
|
+
# You should have received a copy of the GNU General Public License
|
30
|
+
# along with this program; if not, write to the Free Software
|
31
|
+
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
32
|
+
#
|
33
|
+
#---------------------------------------------------------------------------
|
34
|
+
#
|
35
|
+
#
|
36
|
+
|
37
|
+
$:.unshift "../lib"
|
38
|
+
require 'eventmachine'
|
39
|
+
|
40
|
+
class TestHttpClient < Test::Unit::TestCase
|
41
|
+
|
42
|
+
def setup
|
43
|
+
end
|
44
|
+
|
45
|
+
def teardown
|
46
|
+
end
|
47
|
+
|
48
|
+
#-------------------------------------
|
49
|
+
|
50
|
+
def test_http_client
|
51
|
+
ok = false
|
52
|
+
EventMachine.run {
|
53
|
+
c = EventMachine::Protocols::HttpClient.send :request, :host => "www.bayshorenetworks.com", :port => 80
|
54
|
+
c.callback {
|
55
|
+
ok = true
|
56
|
+
EventMachine.stop
|
57
|
+
}
|
58
|
+
c.errback {EventMachine.stop} # necessary, otherwise a failure blocks the test suite forever.
|
59
|
+
}
|
60
|
+
assert ok
|
61
|
+
end
|
62
|
+
|
63
|
+
#-------------------------------------
|
64
|
+
|
65
|
+
def test_http_client_1
|
66
|
+
ok = false
|
67
|
+
EventMachine.run {
|
68
|
+
c = EventMachine::Protocols::HttpClient.send :request, :host => "www.bayshorenetworks.com", :port => 80
|
69
|
+
c.callback {ok = true; EventMachine.stop}
|
70
|
+
c.errback {EventMachine.stop}
|
71
|
+
}
|
72
|
+
assert ok
|
73
|
+
end
|
74
|
+
|
75
|
+
#-------------------------------------
|
76
|
+
|
77
|
+
def test_http_client_2
|
78
|
+
ok = false
|
79
|
+
EventMachine.run {
|
80
|
+
c = EventMachine::Protocols::HttpClient.send :request, :host => "www.bayshorenetworks.com", :port => 80
|
81
|
+
c.callback {|result|
|
82
|
+
p result
|
83
|
+
ok = true;
|
84
|
+
EventMachine.stop
|
85
|
+
}
|
86
|
+
c.errback {EventMachine.stop}
|
87
|
+
}
|
88
|
+
assert ok
|
89
|
+
end
|
90
|
+
|
91
|
+
|
92
|
+
end
|
93
|
+
|
94
|
+
|
data/tests/test_ltp.rb
ADDED
@@ -0,0 +1,192 @@
|
|
1
|
+
# $Id: test_ltp.rb 278 2006-11-16 15:54:52Z blackhedd $
|
2
|
+
#
|
3
|
+
# Author:: blackhedd (gmail address: garbagecat10).
|
4
|
+
# Date:: 8 Apr 2006
|
5
|
+
#
|
6
|
+
# Copyright (C) 2006 by Francis Cianfrocca. All Rights Reserved.
|
7
|
+
#
|
8
|
+
# This program is made available under the terms of the GPL version 2.
|
9
|
+
#
|
10
|
+
# See EventMachine and EventMachine::Connection for documentation and
|
11
|
+
# usage examples.
|
12
|
+
#
|
13
|
+
#----------------------------------------------------------------------------
|
14
|
+
#
|
15
|
+
# Copyright (C) 2006 by Francis Cianfrocca. All Rights Reserved.
|
16
|
+
#
|
17
|
+
# Gmail: garbagecat10
|
18
|
+
#
|
19
|
+
# This program is free software; you can redistribute it and/or modify
|
20
|
+
# it under the terms of the GNU General Public License as published by
|
21
|
+
# the Free Software Foundation; either version 2 of the License, or
|
22
|
+
# (at your option) any later version.
|
23
|
+
#
|
24
|
+
# This program is distributed in the hope that it will be useful,
|
25
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
26
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
27
|
+
# GNU General Public License for more details.
|
28
|
+
#
|
29
|
+
# You should have received a copy of the GNU General Public License
|
30
|
+
# along with this program; if not, write to the Free Software
|
31
|
+
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
32
|
+
#
|
33
|
+
#---------------------------------------------------------------------------
|
34
|
+
#
|
35
|
+
#
|
36
|
+
|
37
|
+
$:.unshift "../lib"
|
38
|
+
require 'eventmachine'
|
39
|
+
|
40
|
+
class TestLineAndTextProtocol < Test::Unit::TestCase
|
41
|
+
|
42
|
+
TestHost = "127.0.0.1"
|
43
|
+
TestPort = 8905
|
44
|
+
|
45
|
+
|
46
|
+
#--------------------------------------------------------------------
|
47
|
+
|
48
|
+
class SimpleLineTest < EventMachine::Protocols::LineAndTextProtocol
|
49
|
+
def receive_line line
|
50
|
+
@line_buffer << line
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_simple_lines
|
55
|
+
lines_received = []
|
56
|
+
Thread.abort_on_exception = true
|
57
|
+
EventMachine.run {
|
58
|
+
EventMachine.start_server( TestHost, TestPort, SimpleLineTest ) do |conn|
|
59
|
+
conn.instance_eval "@line_buffer = lines_received"
|
60
|
+
end
|
61
|
+
EventMachine.add_timer(4) {raise "test timed out"}
|
62
|
+
EventMachine.defer proc {
|
63
|
+
t = TCPSocket.new TestHost, TestPort
|
64
|
+
t.write [
|
65
|
+
"aaa\n", "bbb\r\n", "ccc\n"
|
66
|
+
].join
|
67
|
+
t.close
|
68
|
+
}, proc {
|
69
|
+
EventMachine.stop
|
70
|
+
}
|
71
|
+
}
|
72
|
+
assert_equal( %w(aaa bbb ccc), lines_received )
|
73
|
+
end
|
74
|
+
|
75
|
+
#--------------------------------------------------------------------
|
76
|
+
|
77
|
+
class SimpleLineTest < EventMachine::Protocols::LineAndTextProtocol
|
78
|
+
def receive_error text
|
79
|
+
@error_message << text
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def test_overlength_lines
|
84
|
+
lines_received = []
|
85
|
+
Thread.abort_on_exception = true
|
86
|
+
EventMachine.run {
|
87
|
+
EventMachine.start_server( TestHost, TestPort, SimpleLineTest ) do |conn|
|
88
|
+
conn.instance_eval "@error_message = lines_received"
|
89
|
+
end
|
90
|
+
EventMachine.add_timer(4) {raise "test timed out"}
|
91
|
+
EventMachine.defer proc {
|
92
|
+
t = TCPSocket.new TestHost, TestPort
|
93
|
+
t.write "a" * (16*1024 + 1)
|
94
|
+
t.write "\n"
|
95
|
+
t.close
|
96
|
+
}, proc {
|
97
|
+
EventMachine.stop
|
98
|
+
}
|
99
|
+
}
|
100
|
+
assert_equal( ["overlength line"], lines_received )
|
101
|
+
end
|
102
|
+
|
103
|
+
|
104
|
+
#--------------------------------------------------------------------
|
105
|
+
|
106
|
+
class LineAndTextTest < EventMachine::Protocols::LineAndTextProtocol
|
107
|
+
def post_init
|
108
|
+
end
|
109
|
+
def receive_line line
|
110
|
+
if line =~ /content-length:\s*(\d+)/i
|
111
|
+
@content_lenth = $1.to_i
|
112
|
+
elsif line.length == 0
|
113
|
+
set_binary_mode @content_length
|
114
|
+
end
|
115
|
+
end
|
116
|
+
def receive_binary_data text
|
117
|
+
send_data "received #{text.length} bytes"
|
118
|
+
close_connection_after_writing
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
def test_lines_and_text
|
123
|
+
output = nil
|
124
|
+
lines_received = []
|
125
|
+
text_received = []
|
126
|
+
Thread.abort_on_exception = true
|
127
|
+
EventMachine.run {
|
128
|
+
EventMachine.start_server( TestHost, TestPort, LineAndTextTest ) do |conn|
|
129
|
+
conn.instance_eval "@lines = lines_received; @text = text_received"
|
130
|
+
end
|
131
|
+
EventMachine.add_timer(4) {raise "test timed out"}
|
132
|
+
EventMachine.defer proc {
|
133
|
+
t = TCPSocket.new TestHost, TestPort
|
134
|
+
t.puts "Content-length: 400"
|
135
|
+
t.puts
|
136
|
+
t.write "A" * 400
|
137
|
+
output = t.read
|
138
|
+
t.close
|
139
|
+
}, proc {
|
140
|
+
EventMachine.stop
|
141
|
+
}
|
142
|
+
}
|
143
|
+
assert_equal( "received 400 bytes", output )
|
144
|
+
end
|
145
|
+
|
146
|
+
#--------------------------------------------------------------------
|
147
|
+
|
148
|
+
|
149
|
+
class BinaryTextTest < EventMachine::Protocols::LineAndTextProtocol
|
150
|
+
def post_init
|
151
|
+
end
|
152
|
+
def receive_line line
|
153
|
+
if line =~ /content-length:\s*(\d+)/i
|
154
|
+
set_binary_mode $1.to_i
|
155
|
+
else
|
156
|
+
raise "protocol error"
|
157
|
+
end
|
158
|
+
end
|
159
|
+
def receive_binary_data text
|
160
|
+
send_data "received #{text.length} bytes"
|
161
|
+
close_connection_after_writing
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
def test_binary_text
|
166
|
+
output = nil
|
167
|
+
lines_received = []
|
168
|
+
text_received = []
|
169
|
+
Thread.abort_on_exception = true
|
170
|
+
EventMachine.run {
|
171
|
+
EventMachine.start_server( TestHost, TestPort, BinaryTextTest ) do |conn|
|
172
|
+
conn.instance_eval "@lines = lines_received; @text = text_received"
|
173
|
+
end
|
174
|
+
EventMachine.add_timer(4) {raise "test timed out"}
|
175
|
+
EventMachine.defer proc {
|
176
|
+
t = TCPSocket.new TestHost, TestPort
|
177
|
+
t.puts "Content-length: 10000"
|
178
|
+
t.write "A" * 10000
|
179
|
+
output = t.read
|
180
|
+
t.close
|
181
|
+
}, proc {
|
182
|
+
EventMachine.stop
|
183
|
+
}
|
184
|
+
}
|
185
|
+
assert_equal( "received 10000 bytes", output )
|
186
|
+
end
|
187
|
+
|
188
|
+
#--------------------------------------------------------------------
|
189
|
+
|
190
|
+
end
|
191
|
+
|
192
|
+
|
data/tests/test_ud.rb
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
# $Id: test_ud.rb 269 2006-10-25 23:31:15Z blackhedd $
|
2
|
+
#
|
3
|
+
# Author:: blackhedd (gmail address: garbagecat10).
|
4
|
+
# Date:: 8 Apr 2006
|
5
|
+
#
|
6
|
+
# Copyright (C) 2006 by Francis Cianfrocca. All Rights Reserved.
|
7
|
+
#
|
8
|
+
# This program is made available under the terms of the GPL version 2.
|
9
|
+
#
|
10
|
+
# See EventMachine and EventMachine::Connection for documentation and
|
11
|
+
# usage examples.
|
12
|
+
#
|
13
|
+
#----------------------------------------------------------------------------
|
14
|
+
#
|
15
|
+
# Copyright (C) 2006 by Francis Cianfrocca. All Rights Reserved.
|
16
|
+
#
|
17
|
+
# Gmail: garbagecat10
|
18
|
+
#
|
19
|
+
# This program is free software; you can redistribute it and/or modify
|
20
|
+
# it under the terms of the GNU General Public License as published by
|
21
|
+
# the Free Software Foundation; either version 2 of the License, or
|
22
|
+
# (at your option) any later version.
|
23
|
+
#
|
24
|
+
# This program is distributed in the hope that it will be useful,
|
25
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
26
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
27
|
+
# GNU General Public License for more details.
|
28
|
+
#
|
29
|
+
# You should have received a copy of the GNU General Public License
|
30
|
+
# along with this program; if not, write to the Free Software
|
31
|
+
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
32
|
+
#
|
33
|
+
#---------------------------------------------------------------------------
|
34
|
+
#
|
35
|
+
#
|
36
|
+
|
37
|
+
$:.unshift "../lib"
|
38
|
+
require 'eventmachine'
|
39
|
+
|
40
|
+
class TestUserDefinedEvents < Test::Unit::TestCase
|
41
|
+
|
42
|
+
def setup
|
43
|
+
end
|
44
|
+
|
45
|
+
def teardown
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_a
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
|
metadata
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.
|
2
|
+
rubygems_version: 0.9.0
|
3
3
|
specification_version: 1
|
4
4
|
name: eventmachine-win32
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.
|
7
|
-
date: 2006-
|
6
|
+
version: 0.7.0
|
7
|
+
date: 2006-11-22 00:00:00 -05:00
|
8
8
|
summary: Ruby/EventMachine socket engine library- binary gem for Win32
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -25,15 +25,40 @@ required_ruby_version: !ruby/object:Gem::Version::Requirement
|
|
25
25
|
platform: ruby
|
26
26
|
signing_key:
|
27
27
|
cert_chain:
|
28
|
+
post_install_message:
|
28
29
|
authors:
|
29
30
|
- Francis Cianfrocca
|
30
31
|
files:
|
31
32
|
- tests/testem.rb
|
33
|
+
- tests/test_basic.rb
|
34
|
+
- tests/test_eventables.rb
|
35
|
+
- tests/test_hc.rb
|
36
|
+
- tests/test_httpclient.rb
|
37
|
+
- tests/test_ltp.rb
|
38
|
+
- tests/test_ud.rb
|
39
|
+
- lib/em
|
32
40
|
- lib/eventmachine.rb
|
41
|
+
- lib/eventmachine_version.rb
|
42
|
+
- lib/evma
|
43
|
+
- lib/evma.rb
|
44
|
+
- lib/protocols
|
45
|
+
- lib/pr_eventmachine.rb
|
33
46
|
- lib/rubyeventmachine.so
|
47
|
+
- lib/em/deferrable.rb
|
48
|
+
- lib/em/eventable.rb
|
49
|
+
- lib/evma/callback.rb
|
50
|
+
- lib/evma/container.rb
|
51
|
+
- lib/evma/factory.rb
|
52
|
+
- lib/evma/protocol.rb
|
53
|
+
- lib/evma/reactor.rb
|
54
|
+
- lib/protocols/header_and_content.rb
|
55
|
+
- lib/protocols/httpclient.rb
|
56
|
+
- lib/protocols/line_and_text.rb
|
57
|
+
- lib/protocols/tcptest.rb
|
34
58
|
- README
|
35
59
|
- RELEASE_NOTES
|
36
60
|
- COPYING
|
61
|
+
- TODO
|
37
62
|
test_files:
|
38
63
|
- tests/testem.rb
|
39
64
|
rdoc_options:
|
@@ -46,6 +71,7 @@ extra_rdoc_files:
|
|
46
71
|
- README
|
47
72
|
- RELEASE_NOTES
|
48
73
|
- COPYING
|
74
|
+
- TODO
|
49
75
|
executables: []
|
50
76
|
|
51
77
|
extensions: []
|