eventmachine 0.12.6-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (136) hide show
  1. data/.gitignore +13 -0
  2. data/Rakefile +262 -0
  3. data/docs/COPYING +60 -0
  4. data/docs/ChangeLog +211 -0
  5. data/docs/DEFERRABLES +138 -0
  6. data/docs/EPOLL +141 -0
  7. data/docs/GNU +281 -0
  8. data/docs/INSTALL +15 -0
  9. data/docs/KEYBOARD +38 -0
  10. data/docs/LEGAL +25 -0
  11. data/docs/LIGHTWEIGHT_CONCURRENCY +72 -0
  12. data/docs/PURE_RUBY +77 -0
  13. data/docs/README +74 -0
  14. data/docs/RELEASE_NOTES +96 -0
  15. data/docs/SMTP +9 -0
  16. data/docs/SPAWNED_PROCESSES +93 -0
  17. data/docs/TODO +10 -0
  18. data/eventmachine.gemspec +32 -0
  19. data/ext/binder.cpp +126 -0
  20. data/ext/binder.h +48 -0
  21. data/ext/cmain.cpp +586 -0
  22. data/ext/cplusplus.cpp +193 -0
  23. data/ext/ed.cpp +1522 -0
  24. data/ext/ed.h +380 -0
  25. data/ext/em.cpp +1937 -0
  26. data/ext/em.h +186 -0
  27. data/ext/emwin.cpp +300 -0
  28. data/ext/emwin.h +94 -0
  29. data/ext/epoll.cpp +26 -0
  30. data/ext/epoll.h +25 -0
  31. data/ext/eventmachine.h +98 -0
  32. data/ext/eventmachine_cpp.h +95 -0
  33. data/ext/extconf.rb +129 -0
  34. data/ext/fastfilereader/extconf.rb +77 -0
  35. data/ext/fastfilereader/mapper.cpp +214 -0
  36. data/ext/fastfilereader/mapper.h +59 -0
  37. data/ext/fastfilereader/rubymain.cpp +127 -0
  38. data/ext/files.cpp +94 -0
  39. data/ext/files.h +65 -0
  40. data/ext/kb.cpp +82 -0
  41. data/ext/page.cpp +107 -0
  42. data/ext/page.h +51 -0
  43. data/ext/pipe.cpp +351 -0
  44. data/ext/project.h +119 -0
  45. data/ext/rubymain.cpp +847 -0
  46. data/ext/sigs.cpp +89 -0
  47. data/ext/sigs.h +32 -0
  48. data/ext/ssl.cpp +423 -0
  49. data/ext/ssl.h +90 -0
  50. data/java/.classpath +8 -0
  51. data/java/.project +17 -0
  52. data/java/src/com/rubyeventmachine/Application.java +196 -0
  53. data/java/src/com/rubyeventmachine/Connection.java +74 -0
  54. data/java/src/com/rubyeventmachine/ConnectionFactory.java +37 -0
  55. data/java/src/com/rubyeventmachine/DefaultConnectionFactory.java +46 -0
  56. data/java/src/com/rubyeventmachine/EmReactor.java +408 -0
  57. data/java/src/com/rubyeventmachine/EmReactorException.java +40 -0
  58. data/java/src/com/rubyeventmachine/EventableChannel.java +57 -0
  59. data/java/src/com/rubyeventmachine/EventableDatagramChannel.java +171 -0
  60. data/java/src/com/rubyeventmachine/EventableSocketChannel.java +244 -0
  61. data/java/src/com/rubyeventmachine/PeriodicTimer.java +38 -0
  62. data/java/src/com/rubyeventmachine/Timer.java +54 -0
  63. data/java/src/com/rubyeventmachine/tests/ApplicationTest.java +108 -0
  64. data/java/src/com/rubyeventmachine/tests/ConnectTest.java +124 -0
  65. data/java/src/com/rubyeventmachine/tests/EMTest.java +80 -0
  66. data/java/src/com/rubyeventmachine/tests/TestDatagrams.java +53 -0
  67. data/java/src/com/rubyeventmachine/tests/TestServers.java +74 -0
  68. data/java/src/com/rubyeventmachine/tests/TestTimers.java +89 -0
  69. data/lib/em/deferrable.rb +208 -0
  70. data/lib/em/eventable.rb +39 -0
  71. data/lib/em/future.rb +62 -0
  72. data/lib/em/messages.rb +66 -0
  73. data/lib/em/processes.rb +113 -0
  74. data/lib/em/spawnable.rb +88 -0
  75. data/lib/em/streamer.rb +112 -0
  76. data/lib/eventmachine.rb +1926 -0
  77. data/lib/eventmachine_version.rb +31 -0
  78. data/lib/evma.rb +32 -0
  79. data/lib/evma/callback.rb +32 -0
  80. data/lib/evma/container.rb +75 -0
  81. data/lib/evma/factory.rb +77 -0
  82. data/lib/evma/protocol.rb +87 -0
  83. data/lib/evma/reactor.rb +48 -0
  84. data/lib/jeventmachine.rb +137 -0
  85. data/lib/pr_eventmachine.rb +1011 -0
  86. data/lib/protocols/buftok.rb +127 -0
  87. data/lib/protocols/header_and_content.rb +129 -0
  88. data/lib/protocols/httpcli2.rb +803 -0
  89. data/lib/protocols/httpclient.rb +270 -0
  90. data/lib/protocols/line_and_text.rb +126 -0
  91. data/lib/protocols/linetext2.rb +161 -0
  92. data/lib/protocols/memcache.rb +293 -0
  93. data/lib/protocols/postgres.rb +261 -0
  94. data/lib/protocols/saslauth.rb +179 -0
  95. data/lib/protocols/smtpclient.rb +308 -0
  96. data/lib/protocols/smtpserver.rb +556 -0
  97. data/lib/protocols/stomp.rb +153 -0
  98. data/lib/protocols/tcptest.rb +57 -0
  99. data/setup.rb +1585 -0
  100. data/tasks/cpp.rake +77 -0
  101. data/tasks/project.rake +78 -0
  102. data/tasks/tests.rake +193 -0
  103. data/tests/test_attach.rb +83 -0
  104. data/tests/test_basic.rb +231 -0
  105. data/tests/test_connection_count.rb +45 -0
  106. data/tests/test_defer.rb +47 -0
  107. data/tests/test_epoll.rb +163 -0
  108. data/tests/test_error_handler.rb +35 -0
  109. data/tests/test_errors.rb +82 -0
  110. data/tests/test_eventables.rb +77 -0
  111. data/tests/test_exc.rb +58 -0
  112. data/tests/test_futures.rb +214 -0
  113. data/tests/test_handler_check.rb +37 -0
  114. data/tests/test_hc.rb +218 -0
  115. data/tests/test_httpclient.rb +215 -0
  116. data/tests/test_httpclient2.rb +155 -0
  117. data/tests/test_kb.rb +61 -0
  118. data/tests/test_ltp.rb +188 -0
  119. data/tests/test_ltp2.rb +320 -0
  120. data/tests/test_next_tick.rb +109 -0
  121. data/tests/test_processes.rb +95 -0
  122. data/tests/test_pure.rb +129 -0
  123. data/tests/test_running.rb +47 -0
  124. data/tests/test_sasl.rb +74 -0
  125. data/tests/test_send_file.rb +243 -0
  126. data/tests/test_servers.rb +80 -0
  127. data/tests/test_smtpclient.rb +83 -0
  128. data/tests/test_smtpserver.rb +93 -0
  129. data/tests/test_spawn.rb +329 -0
  130. data/tests/test_ssl_args.rb +68 -0
  131. data/tests/test_ssl_methods.rb +50 -0
  132. data/tests/test_timers.rb +148 -0
  133. data/tests/test_ud.rb +43 -0
  134. data/tests/testem.rb +31 -0
  135. data/web/whatis +7 -0
  136. metadata +214 -0
@@ -0,0 +1,58 @@
1
+ # $Id$
2
+ #
3
+ # Author:: Francis Cianfrocca (gmail: blackhedd)
4
+ # Homepage:: http://rubyeventmachine.com
5
+ # Date:: 8 April 2006
6
+ #
7
+ # See EventMachine and EventMachine::Connection for documentation and
8
+ # usage examples.
9
+ #
10
+ #----------------------------------------------------------------------------
11
+ #
12
+ # Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved.
13
+ # Gmail: blackhedd
14
+ #
15
+ # This program is free software; you can redistribute it and/or modify
16
+ # it under the terms of either: 1) the GNU General Public License
17
+ # as published by the Free Software Foundation; either version 2 of the
18
+ # License, or (at your option) any later version; or 2) Ruby's License.
19
+ #
20
+ # See the file COPYING for complete licensing information.
21
+ #
22
+ #---------------------------------------------------------------------------
23
+ #
24
+ #
25
+
26
+ $:.unshift "../lib"
27
+ require 'eventmachine'
28
+ require 'test/unit'
29
+
30
+ class TestSomeExceptions < Test::Unit::TestCase
31
+
32
+
33
+ # Read the commentary in EventMachine#run.
34
+ # This test exercises the ensure block in #run that makes sure
35
+ # EventMachine#release_machine gets called even if an exception is
36
+ # thrown within the user code. Without the ensured call to release_machine,
37
+ # the second call to EventMachine#run will fail with a C++ exception
38
+ # because the machine wasn't cleaned up properly.
39
+
40
+ def test_a
41
+ assert_raises(RuntimeError) {
42
+ EventMachine.run {
43
+ raise "some exception"
44
+ }
45
+ }
46
+ end
47
+
48
+ def test_b
49
+ assert_raises(RuntimeError) {
50
+ EventMachine.run {
51
+ raise "some exception"
52
+ }
53
+ }
54
+ end
55
+
56
+
57
+ end
58
+
@@ -0,0 +1,214 @@
1
+ # $Id$
2
+ #
3
+ # Author:: Francis Cianfrocca (gmail: blackhedd)
4
+ # Homepage:: http://rubyeventmachine.com
5
+ # Date:: 8 April 2006
6
+ #
7
+ # See EventMachine and EventMachine::Connection for documentation and
8
+ # usage examples.
9
+ #
10
+ #----------------------------------------------------------------------------
11
+ #
12
+ # Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved.
13
+ # Gmail: blackhedd
14
+ #
15
+ # This program is free software; you can redistribute it and/or modify
16
+ # it under the terms of either: 1) the GNU General Public License
17
+ # as published by the Free Software Foundation; either version 2 of the
18
+ # License, or (at your option) any later version; or 2) Ruby's License.
19
+ #
20
+ # See the file COPYING for complete licensing information.
21
+ #
22
+ #---------------------------------------------------------------------------
23
+ #
24
+ #
25
+ #
26
+
27
+ $:.unshift "../lib"
28
+ require 'eventmachine'
29
+ require 'test/unit'
30
+
31
+
32
+
33
+ class TestFutures < Test::Unit::TestCase
34
+
35
+ def setup
36
+ end
37
+
38
+ def teardown
39
+ end
40
+
41
+ def test_future
42
+ assert_equal(100, EventMachine::Deferrable.future(100) )
43
+
44
+ p1 = proc { 100 + 1 }
45
+ assert_equal(101, EventMachine::Deferrable.future(p1) )
46
+ end
47
+
48
+
49
+
50
+ class MyFuture
51
+ include EventMachine::Deferrable
52
+ def initialize *args
53
+ super
54
+ set_deferred_status :succeeded, 40
55
+ end
56
+ end
57
+
58
+ class MyErrorFuture
59
+ include EventMachine::Deferrable
60
+ def initialize *args
61
+ super
62
+ set_deferred_status :failed, 41
63
+ end
64
+ end
65
+
66
+
67
+ def test_future_1
68
+ # Call future with one additional argument and it will be treated as a callback.
69
+ def my_future
70
+ MyFuture.new
71
+ end
72
+
73
+ value = nil
74
+ EventMachine::Deferrable.future my_future, proc {|v| value=v}
75
+ assert_equal( 40, value )
76
+ end
77
+
78
+
79
+ def test_future_2
80
+ # Call future with two additional arguments and they will be treated as a callback
81
+ # and an errback.
82
+ value = nil
83
+ EventMachine::Deferrable.future MyErrorFuture.new, nil, proc {|v| value=v}
84
+ assert_equal( 41, value )
85
+ end
86
+
87
+
88
+ def test_future_3
89
+ # Call future with no additional arguments but with a block, and the block will be
90
+ # treated as a callback.
91
+ value = nil
92
+ EventMachine::Deferrable.future MyFuture.new do |v|
93
+ value=v
94
+ end
95
+ assert_equal( 40, value )
96
+ end
97
+
98
+
99
+ class RecursiveCallback
100
+ include EventMachine::Deferrable
101
+ end
102
+
103
+ # A Deferrable callback can call #set_deferred_status to change the values
104
+ # passed to subsequent callbacks.
105
+ #
106
+ def test_recursive_callbacks
107
+ n = 0 # counter assures that all the tests actually run.
108
+ rc = RecursiveCallback.new
109
+ rc.callback {|a|
110
+ assert_equal(100, a)
111
+ n += 1
112
+ rc.set_deferred_status :succeeded, 101, 101
113
+ }
114
+ rc.callback {|a,b|
115
+ assert_equal(101, a)
116
+ assert_equal(101, b)
117
+ n += 1
118
+ rc.set_deferred_status :succeeded, 102, 102, 102
119
+ }
120
+ rc.callback {|a,b,c|
121
+ assert_equal(102, a)
122
+ assert_equal(102, b)
123
+ assert_equal(102, c)
124
+ n += 1
125
+ }
126
+ rc.set_deferred_status :succeeded, 100
127
+ assert_equal(3, n)
128
+ end
129
+
130
+
131
+
132
+ def test_syntactic_sugar
133
+ rc = RecursiveCallback.new
134
+ rc.set_deferred_success 100
135
+ rc.set_deferred_failure 200
136
+ end
137
+
138
+
139
+
140
+ # It doesn't raise an error to set deferred status more than once.
141
+ # In fact, this is a desired and useful idiom when it happens INSIDE
142
+ # a callback or errback.
143
+ # However, it's less useful otherwise, and in fact would generally be
144
+ # indicative of a programming error. However, we would like to be resistant
145
+ # to such errors. So whenever we set deferred status, we also clear BOTH
146
+ # stacks of handlers.
147
+ #
148
+ def test_double_calls
149
+ s = 0
150
+ e = 0
151
+
152
+ d = EM::DefaultDeferrable.new
153
+ d.callback {s += 1}
154
+ d.errback {e += 1}
155
+
156
+ d.succeed # We expect the callback to be called, and the errback to be DISCARDED.
157
+ d.fail # Presumably an error. We expect the errback NOT to be called.
158
+ d.succeed # We expect the callback to have been discarded and NOT to be called again.
159
+
160
+ assert_equal(1, s)
161
+ assert_equal(0, e)
162
+ end
163
+
164
+
165
+ # Adding a callback to a Deferrable that is already in a success state executes the callback
166
+ # immediately. The same applies to a an errback added to an already-failed Deferrable.
167
+ # HOWEVER, we expect NOT to be able to add errbacks to succeeded Deferrables, or callbacks
168
+ # to failed ones.
169
+ #
170
+ # We illustrate this with a rather contrived test. The test calls #fail after #succeed,
171
+ # which ordinarily would not happen in a real program.
172
+ #
173
+ # What we're NOT attempting to specify is what happens if a Deferrable is succeeded and then
174
+ # failed (or vice-versa). Should we then be able to add callbacks/errbacks of the appropriate
175
+ # type for immediate execution? For now at least, the official answer is "don't do that."
176
+ #
177
+ def test_delayed_callbacks
178
+ s1 = 0
179
+ s2 = 0
180
+ e = 0
181
+
182
+ d = EM::DefaultDeferrable.new
183
+ d.callback {s1 += 1}
184
+
185
+ d.succeed # Triggers and discards the callback.
186
+
187
+ d.callback {s2 += 1} # This callback is executed immediately and discarded.
188
+
189
+ d.errback {e += 1} # This errback should be DISCARDED and never execute.
190
+ d.fail # To prove it, let's
191
+
192
+ assert_equal( [1,1], [s1,s2] )
193
+ assert_equal( 0, e )
194
+ end
195
+
196
+
197
+
198
+
199
+ #
200
+ #
201
+ #
202
+ def test_timeout
203
+ n = 0
204
+ EM.run {
205
+ d = EM::DefaultDeferrable.new
206
+ d.callback {n = 1; EM.stop}
207
+ d.errback {n = 2; EM.stop}
208
+ d.timeout(1)
209
+ }
210
+ assert_equal( 2, n )
211
+ end
212
+
213
+ end
214
+
@@ -0,0 +1,37 @@
1
+ $:.unshift "../lib"
2
+ require 'eventmachine'
3
+ require 'test/unit'
4
+
5
+ class TestHandlerCheck < Test::Unit::TestCase
6
+
7
+ class Foo < EM::Connection; end;
8
+ module TestModule; end;
9
+
10
+ def test_with_correct_class
11
+ assert_nothing_raised do
12
+ EM.run {
13
+ EM.connect("127.0.0.1", 80, Foo)
14
+ EM.stop_event_loop
15
+ }
16
+ end
17
+ end
18
+
19
+ def test_with_incorrect_class
20
+ assert_raise(ArgumentError) do
21
+ EM.run {
22
+ EM.connect("127.0.0.1", 80, String)
23
+ EM.stop_event_loop
24
+ }
25
+ end
26
+ end
27
+
28
+ def test_with_module
29
+ assert_nothing_raised do
30
+ EM.run {
31
+ EM.connect("127.0.0.1", 80, TestModule)
32
+ EM.stop_event_loop
33
+ }
34
+ end
35
+ end
36
+
37
+ end
@@ -0,0 +1,218 @@
1
+ # $Id$
2
+ #
3
+ # Author:: Francis Cianfrocca (gmail: blackhedd)
4
+ # Homepage:: http://rubyeventmachine.com
5
+ # Date:: 8 April 2006
6
+ #
7
+ # See EventMachine and EventMachine::Connection for documentation and
8
+ # usage examples.
9
+ #
10
+ #----------------------------------------------------------------------------
11
+ #
12
+ # Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved.
13
+ # Gmail: blackhedd
14
+ #
15
+ # This program is free software; you can redistribute it and/or modify
16
+ # it under the terms of either: 1) the GNU General Public License
17
+ # as published by the Free Software Foundation; either version 2 of the
18
+ # License, or (at your option) any later version; or 2) Ruby's License.
19
+ #
20
+ # See the file COPYING for complete licensing information.
21
+ #
22
+ #---------------------------------------------------------------------------
23
+ #
24
+ #
25
+ #
26
+
27
+ # $:.unshift "../lib"
28
+ require 'eventmachine'
29
+ require 'test/unit'
30
+
31
+ class TestHeaderAndContentProtocol < Test::Unit::TestCase
32
+
33
+ TestHost = "127.0.0.1"
34
+ TestPort = 8905
35
+
36
+ class SimpleTest < EventMachine::Protocols::HeaderAndContentProtocol
37
+ attr_reader :first_header, :my_headers, :request
38
+
39
+ def receive_first_header_line hdr
40
+ @first_header ||= []
41
+ @first_header << hdr
42
+ end
43
+ def receive_headers hdrs
44
+ @my_headers ||= []
45
+ @my_headers << hdrs
46
+ end
47
+ def receive_request hdrs, content
48
+ @request ||= []
49
+ @request << [hdrs, content]
50
+ end
51
+ end
52
+
53
+ def test_no_content
54
+ the_connection = nil
55
+ EventMachine.run {
56
+ EventMachine.start_server( TestHost, TestPort, SimpleTest ) do |conn|
57
+ the_connection = conn
58
+ end
59
+ EventMachine.add_timer(4) {raise "test timed out"}
60
+
61
+ client = Module.new do
62
+ def unbind
63
+ EM.add_timer(0.1) { EM.stop }
64
+ end
65
+
66
+ def post_init
67
+ send_data [ "aaa\n", "bbb\r\n", "ccc\n", "\n" ].join
68
+ close_connection_after_writing
69
+ end
70
+ end
71
+
72
+ EventMachine.connect( TestHost, TestPort, client )
73
+ }
74
+ assert_equal( ["aaa"], the_connection.first_header )
75
+ assert_equal( [%w(aaa bbb ccc)], the_connection.my_headers )
76
+ assert_equal( [[%w(aaa bbb ccc), ""]], the_connection.request )
77
+ end
78
+
79
+ def test_content
80
+ the_connection = nil
81
+ content = "A" * 50
82
+ headers = ["aaa", "bbb", "Content-length: #{content.length}", "ccc"]
83
+ EventMachine.run {
84
+ EventMachine.start_server( TestHost, TestPort, SimpleTest ) do |conn|
85
+ the_connection = conn
86
+ end
87
+ EventMachine.add_timer(4) { assert(false, 'test timeout'); EM.stop }
88
+
89
+ client = Module.new do
90
+ define_method(:headers) { headers }
91
+ define_method(:content) { content }
92
+
93
+ def unbind
94
+ EM.add_timer(0.1) { EM.stop }
95
+ end
96
+
97
+ def post_init
98
+ headers.each { |h| send_data "#{h}\r\n" }
99
+ send_data "\n"
100
+ send_data content
101
+ close_connection_after_writing
102
+ end
103
+ end
104
+
105
+ EventMachine.connect( TestHost, TestPort, client )
106
+
107
+ }
108
+ assert_equal( ["aaa"], the_connection.first_header )
109
+ assert_equal( [headers], the_connection.my_headers )
110
+ assert_equal( [[headers, content]], the_connection.request )
111
+ end
112
+
113
+ def test_several_requests
114
+ the_connection = nil
115
+ content = "A" * 50
116
+ headers = ["aaa", "bbb", "Content-length: #{content.length}", "ccc"]
117
+ EventMachine.run {
118
+ EventMachine.start_server( TestHost, TestPort, SimpleTest ) do |conn|
119
+ the_connection = conn
120
+ end
121
+ EventMachine.add_timer(4) { assert(false, 'test timeout'); EM.stop }
122
+
123
+ client = Module.new do
124
+ define_method(:headers) { headers }
125
+ define_method(:content) { content }
126
+
127
+ def unbind
128
+ EM.add_timer(0.1) { EM.stop }
129
+ end
130
+
131
+ def post_init
132
+ 5.times do
133
+ headers.each { |h| send_data "#{h}\r\n" }
134
+ send_data "\n"
135
+ send_data content
136
+ end
137
+ close_connection_after_writing
138
+ end
139
+ end
140
+
141
+ EventMachine.connect( TestHost, TestPort, client )
142
+ }
143
+ assert_equal( ["aaa"] * 5, the_connection.first_header )
144
+ assert_equal( [headers] * 5, the_connection.my_headers )
145
+ assert_equal( [[headers, content]] * 5, the_connection.request )
146
+ end
147
+
148
+
149
+ # def x_test_multiple_content_length_headers
150
+ # # This is supposed to throw a RuntimeError but it throws a C++ exception instead.
151
+ # the_connection = nil
152
+ # content = "A" * 50
153
+ # headers = ["aaa", "bbb", ["Content-length: #{content.length}"]*2, "ccc"].flatten
154
+ # EventMachine.run {
155
+ # EventMachine.start_server( TestHost, TestPort, SimpleTest ) do |conn|
156
+ # the_connection = conn
157
+ # end
158
+ # EventMachine.add_timer(4) {raise "test timed out"}
159
+ # test_proc = proc {
160
+ # t = TCPSocket.new TestHost, TestPort
161
+ # headers.each {|h| t.write "#{h}\r\n" }
162
+ # t.write "\n"
163
+ # t.write content
164
+ # t.close
165
+ # }
166
+ # EventMachine.defer test_proc, proc {
167
+ # EventMachine.stop
168
+ # }
169
+ # }
170
+ # end
171
+
172
+ def test_interpret_headers
173
+ the_connection = nil
174
+ content = "A" * 50
175
+ headers = [
176
+ "GET / HTTP/1.0",
177
+ "Accept: aaa",
178
+ "User-Agent: bbb",
179
+ "Host: ccc",
180
+ "x-tempest-header:ddd"
181
+ ]
182
+
183
+ EventMachine.run {
184
+ EventMachine.start_server( TestHost, TestPort, SimpleTest ) do |conn|
185
+ the_connection = conn
186
+ end
187
+ EventMachine.add_timer(4) {raise "test timed out"}
188
+
189
+ client = Module.new do
190
+ define_method(:headers) { headers }
191
+ define_method(:content) { content }
192
+
193
+ def unbind
194
+ EM.add_timer(0.1) { EM.stop }
195
+ end
196
+
197
+ def post_init
198
+ headers.each { |h| send_data "#{h}\r\n" }
199
+ send_data "\n"
200
+ send_data content
201
+ close_connection_after_writing
202
+ end
203
+ end
204
+
205
+ EventMachine.connect( TestHost, TestPort, client )
206
+ }
207
+
208
+ hsh = the_connection.headers_2_hash( the_connection.my_headers.shift )
209
+ expect = {
210
+ :accept => "aaa",
211
+ :user_agent => "bbb",
212
+ :host => "ccc",
213
+ :x_tempest_header => "ddd"
214
+ }
215
+ assert_equal(expect, hsh)
216
+ end
217
+
218
+ end