eventmachine 0.12.6-java → 0.12.8-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (116) hide show
  1. data/{docs/README → README} +21 -13
  2. data/Rakefile +5 -3
  3. data/docs/DEFERRABLES +0 -5
  4. data/docs/INSTALL +2 -4
  5. data/docs/LEGAL +1 -1
  6. data/docs/LIGHTWEIGHT_CONCURRENCY +0 -2
  7. data/docs/PURE_RUBY +0 -2
  8. data/docs/RELEASE_NOTES +0 -2
  9. data/docs/SMTP +0 -7
  10. data/docs/SPAWNED_PROCESSES +0 -4
  11. data/docs/TODO +0 -2
  12. data/eventmachine.gemspec +17 -8
  13. data/examples/ex_channel.rb +43 -0
  14. data/examples/ex_queue.rb +2 -0
  15. data/examples/helper.rb +2 -0
  16. data/ext/cmain.cpp +119 -20
  17. data/ext/cplusplus.cpp +15 -6
  18. data/ext/ed.cpp +303 -93
  19. data/ext/ed.h +49 -22
  20. data/ext/em.cpp +368 -42
  21. data/ext/em.h +43 -6
  22. data/ext/eventmachine.h +21 -8
  23. data/ext/eventmachine_cpp.h +1 -0
  24. data/ext/extconf.rb +4 -0
  25. data/ext/kb.cpp +1 -2
  26. data/ext/pipe.cpp +1 -3
  27. data/ext/project.h +21 -0
  28. data/ext/rubymain.cpp +232 -32
  29. data/ext/ssl.cpp +38 -1
  30. data/ext/ssl.h +5 -1
  31. data/java/src/com/rubyeventmachine/Application.java +7 -3
  32. data/java/src/com/rubyeventmachine/EmReactor.java +16 -1
  33. data/java/src/com/rubyeventmachine/tests/ConnectTest.java +25 -3
  34. data/lib/{protocols → em}/buftok.rb +16 -5
  35. data/lib/em/callback.rb +26 -0
  36. data/lib/em/channel.rb +57 -0
  37. data/lib/em/connection.rb +505 -0
  38. data/lib/em/deferrable.rb +144 -165
  39. data/lib/em/file_watch.rb +54 -0
  40. data/lib/em/future.rb +24 -25
  41. data/lib/em/messages.rb +1 -1
  42. data/lib/em/process_watch.rb +44 -0
  43. data/lib/em/processes.rb +58 -52
  44. data/lib/em/protocols.rb +35 -0
  45. data/lib/em/protocols/header_and_content.rb +138 -0
  46. data/lib/em/protocols/httpclient.rb +263 -0
  47. data/lib/em/protocols/httpclient2.rb +582 -0
  48. data/lib/{protocols → em/protocols}/line_and_text.rb +2 -2
  49. data/lib/em/protocols/linetext2.rb +160 -0
  50. data/lib/{protocols → em/protocols}/memcache.rb +37 -7
  51. data/lib/em/protocols/object_protocol.rb +39 -0
  52. data/lib/em/protocols/postgres3.rb +247 -0
  53. data/lib/em/protocols/saslauth.rb +175 -0
  54. data/lib/em/protocols/smtpclient.rb +331 -0
  55. data/lib/em/protocols/smtpserver.rb +547 -0
  56. data/lib/em/protocols/stomp.rb +200 -0
  57. data/lib/{protocols → em/protocols}/tcptest.rb +21 -25
  58. data/lib/em/queue.rb +61 -0
  59. data/lib/em/spawnable.rb +53 -56
  60. data/lib/em/streamer.rb +92 -74
  61. data/lib/em/timers.rb +55 -0
  62. data/lib/em/version.rb +3 -0
  63. data/lib/eventmachine.rb +1008 -1298
  64. data/lib/evma.rb +1 -1
  65. data/lib/jeventmachine.rb +106 -101
  66. data/lib/pr_eventmachine.rb +47 -36
  67. data/tasks/project.rake +2 -1
  68. data/tests/client.crt +31 -0
  69. data/tests/client.key +51 -0
  70. data/tests/test_attach.rb +18 -0
  71. data/tests/test_basic.rb +108 -54
  72. data/tests/test_channel.rb +63 -0
  73. data/tests/test_connection_count.rb +2 -2
  74. data/tests/test_epoll.rb +109 -110
  75. data/tests/test_errors.rb +36 -36
  76. data/tests/test_exc.rb +22 -25
  77. data/tests/test_file_watch.rb +49 -0
  78. data/tests/test_futures.rb +77 -93
  79. data/tests/test_hc.rb +2 -2
  80. data/tests/test_httpclient.rb +55 -52
  81. data/tests/test_httpclient2.rb +110 -112
  82. data/tests/test_inactivity_timeout.rb +30 -0
  83. data/tests/test_kb.rb +8 -9
  84. data/tests/test_ltp2.rb +274 -277
  85. data/tests/test_next_tick.rb +91 -65
  86. data/tests/test_object_protocol.rb +37 -0
  87. data/tests/test_process_watch.rb +48 -0
  88. data/tests/test_processes.rb +56 -23
  89. data/tests/test_proxy_connection.rb +92 -0
  90. data/tests/test_pure.rb +1 -5
  91. data/tests/test_queue.rb +44 -0
  92. data/tests/test_running.rb +9 -14
  93. data/tests/test_sasl.rb +32 -34
  94. data/tests/test_send_file.rb +175 -176
  95. data/tests/test_servers.rb +37 -41
  96. data/tests/test_smtpserver.rb +47 -55
  97. data/tests/test_spawn.rb +284 -291
  98. data/tests/test_ssl_args.rb +1 -1
  99. data/tests/test_ssl_methods.rb +1 -1
  100. data/tests/test_ssl_verify.rb +82 -0
  101. data/tests/test_timers.rb +81 -88
  102. data/tests/test_ud.rb +0 -7
  103. data/tests/testem.rb +1 -1
  104. metadata +52 -36
  105. data/lib/em/eventable.rb +0 -39
  106. data/lib/eventmachine_version.rb +0 -31
  107. data/lib/protocols/header_and_content.rb +0 -129
  108. data/lib/protocols/httpcli2.rb +0 -803
  109. data/lib/protocols/httpclient.rb +0 -270
  110. data/lib/protocols/linetext2.rb +0 -161
  111. data/lib/protocols/postgres.rb +0 -261
  112. data/lib/protocols/saslauth.rb +0 -179
  113. data/lib/protocols/smtpclient.rb +0 -308
  114. data/lib/protocols/smtpserver.rb +0 -556
  115. data/lib/protocols/stomp.rb +0 -153
  116. data/tests/test_eventables.rb +0 -77
@@ -36,47 +36,47 @@ require 'test/unit'
36
36
 
37
37
  class TestErrors < Test::Unit::TestCase
38
38
 
39
- Localhost = "127.0.0.1"
40
- Localport = 9801
39
+ Localhost = "127.0.0.1"
40
+ Localport = 9801
41
41
 
42
- def setup
43
- end
42
+ def setup
43
+ end
44
44
 
45
- def obsolete_teardown
46
- # Calling #set_runtime_error_hook with no block restores the
47
- # default handling of runtime_errors.
48
- #
49
- EM.set_runtime_error_hook
50
- end
45
+ def obsolete_teardown
46
+ # Calling #set_runtime_error_hook with no block restores the
47
+ # default handling of runtime_errors.
48
+ #
49
+ EM.set_runtime_error_hook
50
+ end
51
51
 
52
- def test_no_tests_stub
53
- end
52
+ def test_no_tests_stub
53
+ end
54
54
 
55
- # EM has a default handler for RuntimeErrors that are emitted from
56
- # user written code. You can override the handler if you wish, but it's
57
- # easier to call #set_runtime_error_hook.
58
- # Ordinarily, an error in user code invoked by the reactor aborts the
59
- # run.
60
- #
61
- def obsolete_test_unhandled_error
62
- assert_raises( RuntimeError ) {
63
- EM.run {
64
- EM.add_timer(0) {raise "AAA"}
65
- }
66
- }
55
+ # EM has a default handler for RuntimeErrors that are emitted from
56
+ # user written code. You can override the handler if you wish, but it's
57
+ # easier to call #set_runtime_error_hook.
58
+ # Ordinarily, an error in user code invoked by the reactor aborts the
59
+ # run.
60
+ #
61
+ def obsolete_test_unhandled_error
62
+ assert_raises( RuntimeError ) {
63
+ EM.run {
64
+ EM.add_timer(0) {raise "AAA"}
65
+ }
66
+ }
67
67
 
68
- end
68
+ end
69
69
 
70
- def obsolete_test_handled_error
71
- err = nil
72
- EM.run {
73
- EM.set_runtime_error_hook {
74
- err = true
75
- EM.stop
76
- }
77
- EM.add_timer(0) {raise "AAA"}
78
- }
79
- assert err
80
- end
70
+ def obsolete_test_handled_error
71
+ err = nil
72
+ EM.run {
73
+ EM.set_runtime_error_hook {
74
+ err = true
75
+ EM.stop
76
+ }
77
+ EM.add_timer(0) {raise "AAA"}
78
+ }
79
+ assert err
80
+ end
81
81
  end
82
82
 
@@ -29,30 +29,27 @@ require 'test/unit'
29
29
 
30
30
  class TestSomeExceptions < Test::Unit::TestCase
31
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
-
32
+ # Read the commentary in EventMachine#run.
33
+ # This test exercises the ensure block in #run that makes sure
34
+ # EventMachine#release_machine gets called even if an exception is
35
+ # thrown within the user code. Without the ensured call to release_machine,
36
+ # the second call to EventMachine#run will fail with a C++ exception
37
+ # because the machine wasn't cleaned up properly.
38
+
39
+ def test_a
40
+ assert_raises(RuntimeError) {
41
+ EventMachine.run {
42
+ raise "some exception"
43
+ }
44
+ }
45
+ end
46
+
47
+ def test_b
48
+ assert_raises(RuntimeError) {
49
+ EventMachine.run {
50
+ raise "some exception"
51
+ }
52
+ }
53
+ end
56
54
 
57
55
  end
58
-
@@ -0,0 +1,49 @@
1
+ $:.unshift "../lib"
2
+ require 'eventmachine'
3
+ require 'test/unit'
4
+
5
+ class TestFileWatch < Test::Unit::TestCase
6
+ module FileWatcher
7
+ def file_modified
8
+ $modified = true
9
+ end
10
+ def file_deleted
11
+ $deleted = true
12
+ end
13
+ def unbind
14
+ $unbind = true
15
+ EM.stop
16
+ end
17
+ end
18
+
19
+ def setup
20
+ EM.kqueue = true if EM.kqueue?
21
+ end
22
+
23
+ def teardown
24
+ EM.kqueue = false if EM.kqueue?
25
+ end
26
+
27
+ def test_events
28
+ EM.run{
29
+ require 'tempfile'
30
+ file = Tempfile.new('em-watch')
31
+ $tmp_path = file.path
32
+
33
+ # watch it
34
+ watch = EM.watch_file(file.path, FileWatcher)
35
+ $path = watch.path
36
+
37
+ # modify it
38
+ File.open(file.path, 'w'){ |f| f.puts 'hi' }
39
+
40
+ # delete it
41
+ EM.add_timer(0.25){ file.close; file.delete }
42
+ }
43
+
44
+ assert_equal($path, $tmp_path)
45
+ assert($modified)
46
+ assert($deleted)
47
+ assert($unbind)
48
+ end
49
+ end
@@ -28,8 +28,6 @@ $:.unshift "../lib"
28
28
  require 'eventmachine'
29
29
  require 'test/unit'
30
30
 
31
-
32
-
33
31
  class TestFutures < Test::Unit::TestCase
34
32
 
35
33
  def setup
@@ -45,21 +43,19 @@ class TestFutures < Test::Unit::TestCase
45
43
  assert_equal(101, EventMachine::Deferrable.future(p1) )
46
44
  end
47
45
 
48
-
49
-
50
46
  class MyFuture
51
47
  include EventMachine::Deferrable
52
48
  def initialize *args
53
- super
54
- set_deferred_status :succeeded, 40
49
+ super
50
+ set_deferred_status :succeeded, 40
55
51
  end
56
52
  end
57
53
 
58
54
  class MyErrorFuture
59
55
  include EventMachine::Deferrable
60
56
  def initialize *args
61
- super
62
- set_deferred_status :failed, 41
57
+ super
58
+ set_deferred_status :failed, 41
63
59
  end
64
60
  end
65
61
 
@@ -67,7 +63,7 @@ class TestFutures < Test::Unit::TestCase
67
63
  def test_future_1
68
64
  # Call future with one additional argument and it will be treated as a callback.
69
65
  def my_future
70
- MyFuture.new
66
+ MyFuture.new
71
67
  end
72
68
 
73
69
  value = nil
@@ -90,7 +86,7 @@ class TestFutures < Test::Unit::TestCase
90
86
  # treated as a callback.
91
87
  value = nil
92
88
  EventMachine::Deferrable.future MyFuture.new do |v|
93
- value=v
89
+ value=v
94
90
  end
95
91
  assert_equal( 40, value )
96
92
  end
@@ -107,108 +103,96 @@ class TestFutures < Test::Unit::TestCase
107
103
  n = 0 # counter assures that all the tests actually run.
108
104
  rc = RecursiveCallback.new
109
105
  rc.callback {|a|
110
- assert_equal(100, a)
111
- n += 1
112
- rc.set_deferred_status :succeeded, 101, 101
106
+ assert_equal(100, a)
107
+ n += 1
108
+ rc.set_deferred_status :succeeded, 101, 101
113
109
  }
114
110
  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
111
+ assert_equal(101, a)
112
+ assert_equal(101, b)
113
+ n += 1
114
+ rc.set_deferred_status :succeeded, 102, 102, 102
119
115
  }
120
116
  rc.callback {|a,b,c|
121
- assert_equal(102, a)
122
- assert_equal(102, b)
123
- assert_equal(102, c)
124
- n += 1
117
+ assert_equal(102, a)
118
+ assert_equal(102, b)
119
+ assert_equal(102, c)
120
+ n += 1
125
121
  }
126
122
  rc.set_deferred_status :succeeded, 100
127
123
  assert_equal(3, n)
128
124
  end
129
125
 
126
+ def test_syntactic_sugar
127
+ rc = RecursiveCallback.new
128
+ rc.set_deferred_success 100
129
+ rc.set_deferred_failure 200
130
+ end
130
131
 
132
+ # It doesn't raise an error to set deferred status more than once.
133
+ # In fact, this is a desired and useful idiom when it happens INSIDE
134
+ # a callback or errback.
135
+ # However, it's less useful otherwise, and in fact would generally be
136
+ # indicative of a programming error. However, we would like to be resistant
137
+ # to such errors. So whenever we set deferred status, we also clear BOTH
138
+ # stacks of handlers.
139
+ #
140
+ def test_double_calls
141
+ s = 0
142
+ e = 0
131
143
 
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
144
+ d = EM::DefaultDeferrable.new
145
+ d.callback {s += 1}
146
+ d.errback {e += 1}
181
147
 
182
- d = EM::DefaultDeferrable.new
183
- d.callback {s1 += 1}
148
+ d.succeed # We expect the callback to be called, and the errback to be DISCARDED.
149
+ d.fail # Presumably an error. We expect the errback NOT to be called.
150
+ d.succeed # We expect the callback to have been discarded and NOT to be called again.
184
151
 
185
- d.succeed # Triggers and discards the callback.
152
+ assert_equal(1, s)
153
+ assert_equal(0, e)
154
+ end
186
155
 
187
- d.callback {s2 += 1} # This callback is executed immediately and discarded.
156
+ # Adding a callback to a Deferrable that is already in a success state executes the callback
157
+ # immediately. The same applies to a an errback added to an already-failed Deferrable.
158
+ # HOWEVER, we expect NOT to be able to add errbacks to succeeded Deferrables, or callbacks
159
+ # to failed ones.
160
+ #
161
+ # We illustrate this with a rather contrived test. The test calls #fail after #succeed,
162
+ # which ordinarily would not happen in a real program.
163
+ #
164
+ # What we're NOT attempting to specify is what happens if a Deferrable is succeeded and then
165
+ # failed (or vice-versa). Should we then be able to add callbacks/errbacks of the appropriate
166
+ # type for immediate execution? For now at least, the official answer is "don't do that."
167
+ #
168
+ def test_delayed_callbacks
169
+ s1 = 0
170
+ s2 = 0
171
+ e = 0
188
172
 
189
- d.errback {e += 1} # This errback should be DISCARDED and never execute.
190
- d.fail # To prove it, let's
173
+ d = EM::DefaultDeferrable.new
174
+ d.callback {s1 += 1}
191
175
 
192
- assert_equal( [1,1], [s1,s2] )
193
- assert_equal( 0, e )
194
- end
176
+ d.succeed # Triggers and discards the callback.
195
177
 
178
+ d.callback {s2 += 1} # This callback is executed immediately and discarded.
196
179
 
180
+ d.errback {e += 1} # This errback should be DISCARDED and never execute.
181
+ d.fail # To prove it, fail and assert e is 0
197
182
 
183
+ assert_equal( [1,1], [s1,s2] )
184
+ assert_equal( 0, e )
185
+ end
198
186
 
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
187
+ def test_timeout
188
+ n = 0
189
+ EM.run {
190
+ d = EM::DefaultDeferrable.new
191
+ d.callback {n = 1; EM.stop}
192
+ d.errback {n = 2; EM.stop}
193
+ d.timeout(1)
194
+ }
195
+ assert_equal( 2, n )
196
+ end
212
197
 
213
198
  end
214
-
@@ -176,7 +176,7 @@ class TestHeaderAndContentProtocol < Test::Unit::TestCase
176
176
  "GET / HTTP/1.0",
177
177
  "Accept: aaa",
178
178
  "User-Agent: bbb",
179
- "Host: ccc",
179
+ "Host: ccc",
180
180
  "x-tempest-header:ddd"
181
181
  ]
182
182
 
@@ -215,4 +215,4 @@ class TestHeaderAndContentProtocol < Test::Unit::TestCase
215
215
  assert_equal(expect, hsh)
216
216
  end
217
217
 
218
- end
218
+ end
@@ -91,23 +91,23 @@ class TestHttpClient < Test::Unit::TestCase
91
91
  #
92
92
  class EmptyContent < EventMachine::Connection
93
93
  def initialize *args
94
- super
94
+ super
95
95
  end
96
96
  def receive_data data
97
- send_data "HTTP/1.0 404 ...\r\nContent-length: 0\r\n\r\n"
98
- close_connection_after_writing
97
+ send_data "HTTP/1.0 404 ...\r\nContent-length: 0\r\n\r\n"
98
+ close_connection_after_writing
99
99
  end
100
100
  end
101
101
 
102
102
  def test_http_empty_content
103
103
  ok = false
104
104
  EventMachine.run {
105
- EventMachine.start_server "127.0.0.1", 9701, EmptyContent
106
- c = EventMachine::Protocols::HttpClient.send :request, :host => "127.0.0.1", :port => 9701
107
- c.callback {|result|
108
- ok = true
109
- EventMachine.stop
110
- }
105
+ EventMachine.start_server "127.0.0.1", 9701, EmptyContent
106
+ c = EventMachine::Protocols::HttpClient.send :request, :host => "127.0.0.1", :port => 9701
107
+ c.callback {|result|
108
+ ok = true
109
+ EventMachine.stop
110
+ }
111
111
  }
112
112
  assert ok
113
113
  end
@@ -117,40 +117,41 @@ class TestHttpClient < Test::Unit::TestCase
117
117
 
118
118
  class PostContent < EventMachine::Protocols::LineAndTextProtocol
119
119
  def initialize *args
120
- super
121
- @lines = []
120
+ super
121
+ @lines = []
122
122
  end
123
123
  def receive_line line
124
- if line.length > 0
125
- @lines << line
126
- else
127
- process_headers
128
- end
124
+ if line.length > 0
125
+ @lines << line
126
+ else
127
+ process_headers
128
+ end
129
129
  end
130
130
  def receive_binary_data data
131
- @post_content = data
132
- send_response
131
+ @post_content = data
132
+ send_response
133
133
  end
134
134
  def process_headers
135
- if @lines.first =~ /\APOST ([^\s]+) HTTP\/1.1\Z/
136
- @uri = $1.dup
137
- else
138
- raise "bad request"
139
- end
140
- @lines.each {|line|
141
- if line =~ /\AContent-length:\s*(\d+)\Z/i
142
- @content_length = $1.dup.to_i
143
- elsif line =~ /\AContent-type:\s*(\d+)\Z/i
144
- @content_type = $1.dup
145
- end
146
- }
147
-
148
- raise "invalid content length" unless @content_length
149
- set_binary_mode @content_length
135
+ if @lines.first =~ /\APOST ([^\s]+) HTTP\/1.1\Z/
136
+ @uri = $1.dup
137
+ else
138
+ raise "bad request"
139
+ end
140
+
141
+ @lines.each {|line|
142
+ if line =~ /\AContent-length:\s*(\d+)\Z/i
143
+ @content_length = $1.dup.to_i
144
+ elsif line =~ /\AContent-type:\s*(\d+)\Z/i
145
+ @content_type = $1.dup
146
+ end
147
+ }
148
+
149
+ raise "invalid content length" unless @content_length
150
+ set_binary_mode @content_length
150
151
  end
151
152
  def send_response
152
- send_data "HTTP/1.1 200 ...\r\nConnection: close\r\nContent-length: 10\r\nContent-type: text/html\r\n\r\n0123456789"
153
- close_connection_after_writing
153
+ send_data "HTTP/1.1 200 ...\r\nConnection: close\r\nContent-length: 10\r\nContent-type: text/html\r\n\r\n0123456789"
154
+ close_connection_after_writing
154
155
  end
155
156
  end
156
157
 
@@ -159,15 +160,20 @@ class TestHttpClient < Test::Unit::TestCase
159
160
  def test_post
160
161
  response = nil
161
162
  EventMachine.run {
162
- EventMachine.start_server Localhost, Localport, PostContent
163
- EventMachine.add_timer(2) {raise "timed out"}
164
- c = EventMachine::Protocols::HttpClient.request :host=>Localhost,
165
- :port=>Localport, :method=>:post, :request=>"/aaa", :content=>"XYZ",
166
- :content_type=>"text/plain"
167
- c.callback {|r|
168
- response = r
169
- EventMachine.stop
170
- }
163
+ EventMachine.start_server Localhost, Localport, PostContent
164
+ EventMachine.add_timer(2) {raise "timed out"}
165
+ c = EventMachine::Protocols::HttpClient.request(
166
+ :host=>Localhost,
167
+ :port=>Localport,
168
+ :method=>:post,
169
+ :request=>"/aaa",
170
+ :content=>"XYZ",
171
+ :content_type=>"text/plain"
172
+ )
173
+ c.callback {|r|
174
+ response = r
175
+ EventMachine.stop
176
+ }
171
177
  }
172
178
 
173
179
  assert_equal( 200, response[:status] )
@@ -190,16 +196,16 @@ class TestHttpClient < Test::Unit::TestCase
190
196
  assert ok
191
197
  end
192
198
 
193
-
194
-
195
199
  # We can tell the client to send an HTTP/1.0 request (default is 1.1).
196
200
  # This is useful for suppressing chunked responses until those are working.
197
201
  def test_version_1_0
198
202
  ok = false
199
203
  EM.run {
200
- c = EM::P::HttpClient.request :host => "www.bayshorenetworks.com",
201
- :port => 80,
202
- :version => "1.0"
204
+ c = EM::P::HttpClient.request(
205
+ :host => "www.bayshorenetworks.com",
206
+ :port => 80,
207
+ :version => "1.0"
208
+ )
203
209
  c.callback {|result|
204
210
  ok = true;
205
211
  EventMachine.stop
@@ -209,7 +215,4 @@ class TestHttpClient < Test::Unit::TestCase
209
215
  assert ok
210
216
  end
211
217
 
212
-
213
218
  end
214
-
215
-