mongrel2 0.48.0 → 0.49.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,6 +2,7 @@
2
2
 
3
3
  require_relative '../helpers'
4
4
 
5
+ require 'ostruct'
5
6
  require 'mongrel2'
6
7
  require 'mongrel2/control'
7
8
 
@@ -17,46 +18,40 @@ describe Mongrel2::Control do
17
18
 
18
19
  before( :each ) do
19
20
  @ctx = double( "ZMQ::Context" )
20
- @socket = double( "ZMQ REQ socket", :connect => nil, :linger= => nil )
21
- allow( @ctx ).to receive( :socket ).with( :REQ ).and_return( @socket )
22
-
23
- Mongrel2.instance_variable_set( :@zmq_ctx, @ctx )
21
+ @socket = double( "ZMQ REQ socket", :connect => nil, :options => OpenStruct.new )
22
+ allow( CZTop::Socket::REQ ).to receive( :new ).and_return( @socket )
24
23
 
25
24
  allow( FileTest ).to receive( :socket? ).with( 'var/run/control' ). and_return( true )
26
25
 
27
26
  @control = Mongrel2::Control.new( 'ipc://var/run/control' )
28
27
  end
29
28
 
30
- after( :all ) do
31
- Mongrel2.instance_variable_set( :@zmq_ctx, nil )
32
- end
33
-
34
29
 
35
30
  it "sends a 'stop' command to the control port when #stop is called" do
36
- expect( @socket ).to receive( :send ).with( "10:4:stop,0:}]" )
37
- expect( @socket ).to receive( :recv ).
38
- and_return( "59:7:headers,6:3:msg,]4:rows,29:25:21:signal sent to server,]]}" )
31
+ expect( @socket ).to receive( :<< ).with( "10:4:stop,0:}]" )
32
+ expect( @socket ).to receive( :receive ).
33
+ and_return( CZTop::Message.new("59:7:headers,6:3:msg,]4:rows,29:25:21:signal sent to server,]]}") )
39
34
  expect( @control.stop ).to eq( [{ :msg => "signal sent to server" }] )
40
35
  end
41
36
 
42
37
  it "sends a 'reload' command to the control port when #reload is called" do
43
- expect( @socket ).to receive( :send ).with( "12:6:reload,0:}]" )
44
- expect( @socket ).to receive( :recv ).
45
- and_return( "59:7:headers,6:3:msg,]4:rows,29:25:21:signal sent to server,]]}" )
38
+ expect( @socket ).to receive( :<< ).with( "12:6:reload,0:}]" )
39
+ expect( @socket ).to receive( :receive ).
40
+ and_return( CZTop::Message.new("59:7:headers,6:3:msg,]4:rows,29:25:21:signal sent to server,]]}") )
46
41
  expect( @control.reload ).to eq( [{ :msg => "signal sent to server" }] )
47
42
  end
48
43
 
49
44
  it "sends a 'terminate' command to the control port when #terminate is called" do
50
- expect( @socket ).to receive( :send ).with( "15:9:terminate,0:}]" )
51
- expect( @socket ).to receive( :recv ).
52
- and_return( "59:7:headers,6:3:msg,]4:rows,29:25:21:signal sent to server,]]}" )
45
+ expect( @socket ).to receive( :<< ).with( "15:9:terminate,0:}]" )
46
+ expect( @socket ).to receive( :receive ).
47
+ and_return( CZTop::Message.new("59:7:headers,6:3:msg,]4:rows,29:25:21:signal sent to server,]]}") )
53
48
  expect( @control.terminate ).to eq( [{ :msg => "signal sent to server" }] )
54
49
  end
55
50
 
56
51
  it "sends a 'help' command to the control port when #help is called" do
57
- expect( @socket ).to receive( :send ).with( "10:4:help,0:}]" )
58
- expect( @socket ).to receive( :recv ).
59
- and_return( "416:7:headers,14:4:name,4:help,]4:rows,376:35:4:stop" +
52
+ expect( @socket ).to receive( :<< ).with( "10:4:help,0:}]" )
53
+ expect( @socket ).to receive( :receive ).and_return(
54
+ CZTop::Message.new("416:7:headers,14:4:name,4:help,]4:rows,376:35:4:stop" +
60
55
  ",24:stop the server (SIGINT),]30:6:reload,17:reload " +
61
56
  "the server,]23:4:help,12:this command,]37:12:control" +
62
57
  "_stop,17:stop control port,]28:4:kill,17:kill a conn" +
@@ -64,7 +59,8 @@ describe Mongrel2::Control do
64
59
  "]46:9:terminate,30:terminate the server (SIGTERM),]2" +
65
60
  "8:4:time,17:the server's time,]28:4:uuid,17:the serv" +
66
61
  "er's uuid,]40:4:info,29:information about this serve" +
67
- "r,]]}" )
62
+ "r,]]}")
63
+ )
68
64
  expect( @control.help ).to eq([
69
65
  {:name => "stop", :help => "stop the server (SIGINT)"},
70
66
  {:name => "reload", :help => "reload the server"},
@@ -80,22 +76,24 @@ describe Mongrel2::Control do
80
76
  end
81
77
 
82
78
  it "sends a 'uuid' command to the control port when #uuid is called" do
83
- expect( @socket ).to receive( :send ).with( "10:4:uuid,0:}]" )
84
- expect( @socket ).to receive( :recv ).
85
- and_return( "75:7:headers,7:4:uuid,]4:rows,44:40:36:34D8E57C-3E91" +
86
- "-4F24-9BBE-0B53C1827CB4,]]}" )
79
+ expect( @socket ).to receive( :<< ).with( "10:4:uuid,0:}]" )
80
+ expect( @socket ).to receive( :receive ).and_return(
81
+ CZTop::Message.new("75:7:headers,7:4:uuid,]4:rows,44:40:36:34D8E57C-3E91" +
82
+ "-4F24-9BBE-0B53C1827CB4,]]}")
83
+ )
87
84
  expect( @control.uuid ).to eq( [{ :uuid => '34D8E57C-3E91-4F24-9BBE-0B53C1827CB4' }] )
88
85
  end
89
86
 
90
87
  it "sends an 'info' command to the control port when #info is called" do
91
- expect( @socket ).to receive( :send ).with( "10:4:info,0:}]" )
92
- expect( @socket ).to receive( :recv ).
93
- and_return( "260:7:headers,92:4:port,9:bind_addr,4:uuid,6:chroot," +
88
+ expect( @socket ).to receive( :<< ).with( "10:4:info,0:}]" )
89
+ expect( @socket ).to receive( :receive ).and_return(
90
+ CZTop::Message.new("260:7:headers,92:4:port,9:bind_addr,4:uuid,6:chroot," +
94
91
  "10:access_log,9:error_log,8:pid_file,16:default_host" +
95
92
  "name,]4:rows,142:137:4:8113#7:0.0.0.0,36:34D8E57C-3E" +
96
93
  "91-4F24-9BBE-0B53C1827CB4,2:./,18:.//logs/access.log" +
97
94
  ",15:/logs/error.log,18:./run/mongrel2.pid,9:localhos" +
98
- "t,]]}" )
95
+ "t,]]}")
96
+ )
99
97
  expect( @control.info ).to eq([{
100
98
  :port => 8113,
101
99
  :bind_addr => "0.0.0.0",
@@ -111,15 +109,16 @@ describe Mongrel2::Control do
111
109
  it "sends a 'status' command with a 'what' option set to 'tasks' to the control port " +
112
110
  "when #tasklist is called" do
113
111
 
114
- expect( @socket ).to receive( :send ).with( "28:6:status,15:4:what,5:tasks,}]" )
115
- expect( @socket ).to receive( :recv ).
116
- and_return( "343:7:headers,38:2:id,6:system,4:name,5:state,6:status," +
112
+ expect( @socket ).to receive( :<< ).with( "28:6:status,15:4:what,5:tasks,}]" )
113
+ expect( @socket ).to receive( :receive ).and_return(
114
+ CZTop::Message.new("343:7:headers,38:2:id,6:system,4:name,5:state,6:status," +
117
115
  "]4:rows,279:38:1:1#5:false!6:SERVER,7:read fd,4:idle,]5" +
118
116
  "1:1:2#5:false!12:Handler_task,12:read handler,4:idle,]5" +
119
117
  "1:1:3#5:false!12:Handler_task,12:read handler,4:idle,]4" +
120
118
  "8:1:4#5:false!7:control,12:read handler,7:running,]31:1" +
121
119
  ":5#5:false!6:ticker,0:,4:idle,]36:1:6#4:true!6:fdtask,5" +
122
- ":yield,5:ready,]]}" )
120
+ ":yield,5:ready,]]}")
121
+ )
123
122
  expect( @control.tasklist ).to eq([
124
123
  {:id=>1, :system=>false, :name=>"SERVER", :state=>"read fd", :status=>"idle"},
125
124
  {:id=>2, :system=>false, :name=>"Handler_task", :state=>"read handler", :status=>"idle"},
@@ -133,11 +132,12 @@ describe Mongrel2::Control do
133
132
  it "sends an 'status' command with a 'what' option set to 'net' to the control port " +
134
133
  "when #conn_status is called" do
135
134
 
136
- expect( @socket ).to receive( :send ).with( "26:6:status,13:4:what,3:net,}]" )
137
- expect( @socket ).to receive( :recv ).
138
- and_return( "150:7:headers,86:2:id,2:fd,4:type,9:last_ping,9:last_read," +
135
+ expect( @socket ).to receive( :<< ).with( "26:6:status,13:4:what,3:net,}]" )
136
+ expect( @socket ).to receive( :receive ).and_return(
137
+ CZTop::Message.new("150:7:headers,86:2:id,2:fd,4:type,9:last_ping,9:last_read," +
139
138
  "10:last_write,10:bytes_read,13:bytes_written,]4:rows,39:35" +
140
- ":1:2#2:38#1:1#1:0#1:0#1:0#3:405#1:0#]]}" )
139
+ ":1:2#2:38#1:1#1:0#1:0#1:0#3:405#1:0#]]}")
140
+ )
141
141
  expect( @control.conn_status ).to eq([
142
142
  {:id=>2, :fd=>38, :type=>1, :last_ping=>0, :last_read=>0, :last_write=>0,
143
143
  :bytes_read=>405, :bytes_written=>0}
@@ -145,31 +145,32 @@ describe Mongrel2::Control do
145
145
  end
146
146
 
147
147
  it "sends a 'time' command to the control port when #time is called" do
148
- expect( @socket ).to receive( :send ).with( "10:4:time,0:}]" )
149
- expect( @socket ).to receive( :recv ).
150
- and_return( "49:7:headers,7:4:time,]4:rows,18:14:10:1315532674,]]}" )
148
+ expect( @socket ).to receive( :<< ).with( "10:4:time,0:}]" )
149
+ expect( @socket ).to receive( :receive ).
150
+ and_return( CZTop::Message.new("49:7:headers,7:4:time,]4:rows,18:14:10:1315532674,]]}") )
151
151
  expect( @control.time ).to eq( Time.at( 1315532674 ) )
152
152
  end
153
153
 
154
154
  it "sends a 'kill' command with an ID equal to the argument to the control port when #kill " +
155
155
  "is called" do
156
- expect( @socket ).to receive( :send ).with( "19:4:kill,9:2:id,1:0#}]" )
157
- expect( @socket ).to receive( :recv ).and_return( "40:7:headers,9:6:status,]4:rows,8:5:2:OK,]]}" )
156
+ expect( @socket ).to receive( :<< ).with( "19:4:kill,9:2:id,1:0#}]" )
157
+ expect( @socket ).to receive( :receive ).
158
+ and_return( CZTop::Message.new( "40:7:headers,9:6:status,]4:rows,8:5:2:OK,]]}" ) )
158
159
  expect( @control.kill( 0 ) ).to eq( [{ :status => "OK" }] )
159
160
  end
160
161
 
161
162
  it "sends a 'control_stop' command to the control port when #info is called" do
162
- expect( @socket ).to receive( :send ).with( "19:12:control_stop,0:}]" )
163
- expect( @socket ).to receive( :recv ).
164
- and_return( "63:7:headers,6:3:msg,]4:rows,33:29:25:stopping the control port,]]}" )
163
+ expect( @socket ).to receive( :<< ).with( "19:12:control_stop,0:}]" )
164
+ expect( @socket ).to receive( :receive ).
165
+ and_return( CZTop::Message.new("63:7:headers,6:3:msg,]4:rows,33:29:25:stopping the control port,]]}") )
165
166
  expect( @control.control_stop ).to eq( [{:msg => "stopping the control port"}] )
166
167
  end
167
168
 
168
169
 
169
170
  it "raises an exception if the server responds with an error" do
170
- expect( @socket ).to receive( :send ).with( "19:4:kill,9:2:id,1:0#}]" )
171
- expect( @socket ).to receive( :recv ).
172
- and_return( "61:4:code,16:INVALID_ARGUMENT,5:error,22:Invalid argument type.,}" )
171
+ expect( @socket ).to receive( :<< ).with( "19:4:kill,9:2:id,1:0#}]" )
172
+ expect( @socket ).to receive( :receive ).
173
+ and_return( CZTop::Message.new("61:4:code,16:INVALID_ARGUMENT,5:error,22:Invalid argument type.,}") )
173
174
 
174
175
  expect {
175
176
  @control.kill( 0 )
@@ -2,6 +2,9 @@
2
2
 
3
3
  require_relative '../helpers'
4
4
 
5
+ require 'ostruct'
6
+ require 'cztop'
7
+
5
8
  require 'mongrel2'
6
9
  require 'mongrel2/config'
7
10
  require 'mongrel2/handler'
@@ -36,20 +39,23 @@ describe Mongrel2::Handler, :db do
36
39
 
37
40
  # Ensure 0MQ never actually gets called
38
41
  before( :each ) do
39
- @ctx = double( '0mq context', close: nil )
40
- @request_sock = double( "request socket", :linger= => nil, :connect => nil, :close => nil )
41
- @response_sock = double( "response socket", :linger= => nil, :connect => nil, :close => nil )
42
-
43
- allow( @ctx ).to receive( :socket ).with( :PULL ).and_return( @request_sock )
44
- allow( @ctx ).to receive( :socket ).with( :PUB ).and_return( @response_sock )
45
-
46
- allow( ZMQ ).to receive( :select ).and_return([ [@request_sock], [], [] ])
47
-
48
- Mongrel2.instance_variable_set( :@zmq_ctx, @ctx )
49
- end
50
-
51
- after( :each ) do
52
- Mongrel2.instance_variable_set( :@zmq_ctx, nil )
42
+ @request_sock = instance_double( CZTop::Socket::PULL, :options => OpenStruct.new, :connect => nil, :close => nil )
43
+ @response_sock = instance_double( CZTop::Socket::PUB, :options => OpenStruct.new, :connect => nil, :close => nil )
44
+ @selfpipe_reader = instance_double( CZTop::Socket::PAIR )
45
+ @selfpipe_writer = instance_double( CZTop::Socket::PAIR )
46
+ @poller = instance_double( CZTop::Poller )
47
+ @poller_event = instance_double( CZTop::Poller::Event )
48
+
49
+ allow( CZTop::Socket::PULL ).to receive( :new ).and_return( @request_sock )
50
+ allow( CZTop::Socket::PUB ).to receive( :new ).and_return( @response_sock )
51
+ allow( CZTop::Socket::PAIR ).to receive( :new ).with( '@inproc://signal-handler' ).
52
+ and_return( @selfpipe_reader )
53
+ allow( CZTop::Socket::PAIR ).to receive( :new ).with( '>inproc://signal-handler' ).
54
+ and_return( @selfpipe_writer )
55
+ allow( CZTop::Poller ).to receive( :new ).and_return( @poller )
56
+
57
+ allow( @poller ).to receive( :wait ).and_return( @poller_event )
58
+ allow( @poller_event ).to receive( :socket ).and_return( @request_sock )
53
59
  end
54
60
 
55
61
 
@@ -78,11 +84,12 @@ describe Mongrel2::Handler, :db do
78
84
  ).to eq([ TEST_SEND_SPEC, TEST_RECV_SPEC ])
79
85
  end
80
86
 
87
+
81
88
  it "has a convenience method for instantiating and running a Handler given an " +
82
89
  "application ID" do
83
90
 
84
91
  req = make_request()
85
- expect( @request_sock ).to receive( :recv ).and_return( req )
92
+ expect( @request_sock ).to receive( :receive ).and_return( CZTop::Message.new( req ) )
86
93
 
87
94
  res = OneShotHandler.run( TEST_UUID )
88
95
 
@@ -92,9 +99,10 @@ describe Mongrel2::Handler, :db do
92
99
  expect( res.conn.pub_addr ).to eq( TEST_RECV_SPEC )
93
100
  end
94
101
 
102
+
95
103
  it "knows what handler config corresponds to its" do
96
104
  req = make_request()
97
- expect( @request_sock ).to receive( :recv ).and_return( req )
105
+ expect( @request_sock ).to receive( :receive ).and_return( CZTop::Message.new( req ) )
98
106
 
99
107
  res = OneShotHandler.run( TEST_UUID )
100
108
 
@@ -124,7 +132,7 @@ describe Mongrel2::Handler, :db do
124
132
 
125
133
  it "dispatches HTTP requests to the #handle method" do
126
134
  req = make_request()
127
- expect( @request_sock ).to receive( :recv ).and_return( req )
135
+ expect( @request_sock ).to receive( :receive ).and_return( CZTop::Message.new( req ) )
128
136
 
129
137
  res = OneShotHandler.new( TEST_UUID, TEST_SEND_SPEC, TEST_RECV_SPEC ).run
130
138
 
@@ -135,9 +143,10 @@ describe Mongrel2::Handler, :db do
135
143
  expect( response.status ).to eq( 204 )
136
144
  end
137
145
 
146
+
138
147
  it "ignores JSON messages by default" do
139
148
  req = make_json_request()
140
- expect( @request_sock ).to receive( :recv ).and_return( req )
149
+ expect( @request_sock ).to receive( :receive ).and_return( CZTop::Message.new( req ) )
141
150
 
142
151
  res = OneShotHandler.new( TEST_UUID, TEST_SEND_SPEC, TEST_RECV_SPEC ).run
143
152
 
@@ -147,6 +156,7 @@ describe Mongrel2::Handler, :db do
147
156
  expect( response ).to be_nil()
148
157
  end
149
158
 
159
+
150
160
  it "dispatches JSON message to the #handle_json method" do
151
161
  json_handler = Class.new( OneShotHandler ) do
152
162
  def handle_json( request )
@@ -155,7 +165,7 @@ describe Mongrel2::Handler, :db do
155
165
  end
156
166
 
157
167
  req = make_json_request()
158
- expect( @request_sock ).to receive( :recv ).and_return( req )
168
+ expect( @request_sock ).to receive( :receive ).and_return( CZTop::Message.new( req ) )
159
169
 
160
170
  res = json_handler.new( TEST_UUID, TEST_SEND_SPEC, TEST_RECV_SPEC ).run
161
171
 
@@ -165,9 +175,10 @@ describe Mongrel2::Handler, :db do
165
175
  expect( response ).to be_a( Mongrel2::Response )
166
176
  end
167
177
 
178
+
168
179
  it "ignores XML messages by default" do
169
180
  req = make_xml_request()
170
- expect( @request_sock ).to receive( :recv ).and_return( req )
181
+ expect( @request_sock ).to receive( :receive ).and_return( CZTop::Message.new( req ) )
171
182
 
172
183
  res = OneShotHandler.new( TEST_UUID, TEST_SEND_SPEC, TEST_RECV_SPEC ).run
173
184
 
@@ -177,6 +188,7 @@ describe Mongrel2::Handler, :db do
177
188
  expect( response ).to be_nil()
178
189
  end
179
190
 
191
+
180
192
  it "dispatches XML message to the #handle_xml method" do
181
193
  xml_handler = Class.new( OneShotHandler ) do
182
194
  def handle_xml( request )
@@ -185,7 +197,7 @@ describe Mongrel2::Handler, :db do
185
197
  end
186
198
 
187
199
  req = make_xml_request()
188
- expect( @request_sock ).to receive( :recv ).and_return( req )
200
+ expect( @request_sock ).to receive( :receive ).and_return( CZTop::Message.new( req ) )
189
201
 
190
202
  res = xml_handler.new( TEST_UUID, TEST_SEND_SPEC, TEST_RECV_SPEC ).run
191
203
 
@@ -195,6 +207,7 @@ describe Mongrel2::Handler, :db do
195
207
  expect( response ).to be_a( Mongrel2::Response )
196
208
  end
197
209
 
210
+
198
211
  it "dispatches WebSocket opening handshakes to the #handle_websocket_handshake method" do
199
212
  ws_handler = Class.new( OneShotHandler ) do
200
213
  def handle_websocket_handshake( handshake )
@@ -203,7 +216,7 @@ describe Mongrel2::Handler, :db do
203
216
  end
204
217
 
205
218
  req = make_websocket_handshake()
206
- expect( @request_sock ).to receive( :recv ).and_return( req )
219
+ expect( @request_sock ).to receive( :receive ).and_return( CZTop::Message.new( req ) )
207
220
 
208
221
  res = ws_handler.new( TEST_UUID, TEST_SEND_SPEC, TEST_RECV_SPEC ).run
209
222
 
@@ -213,6 +226,7 @@ describe Mongrel2::Handler, :db do
213
226
  expect( response ).to be_a( Mongrel2::WebSocket::ServerHandshake )
214
227
  end
215
228
 
229
+
216
230
  it "dispatches WebSocket protocol frames to the #handle_websocket method" do
217
231
  ws_handler = Class.new( OneShotHandler ) do
218
232
  def handle_websocket( frame )
@@ -221,7 +235,7 @@ describe Mongrel2::Handler, :db do
221
235
  end
222
236
 
223
237
  req = make_websocket_frame()
224
- expect( @request_sock ).to receive( :recv ).and_return( req )
238
+ expect( @request_sock ).to receive( :receive ).and_return( CZTop::Message.new( req ) )
225
239
 
226
240
  res = ws_handler.new( TEST_UUID, TEST_SEND_SPEC, TEST_RECV_SPEC ).run
227
241
 
@@ -231,11 +245,13 @@ describe Mongrel2::Handler, :db do
231
245
  expect( response ).to be_a( Mongrel2::WebSocket::Frame )
232
246
  end
233
247
 
234
- it "continues when a ZMQ::Error is received but the connection remains open" do
248
+
249
+ it "continues when a SocketError is received but the connection remains open" do
250
+ pending "Does this still apply?"
235
251
  req = make_request()
236
252
 
237
- expect( @request_sock ).to receive( :recv ).and_raise( ZMQ::Error.new("Interrupted system call.") )
238
- expect( @request_sock ).to receive( :recv ).and_return( req )
253
+ expect( @request_sock ).to receive( :receive ).and_raise( SocketError.new("Interrupted system call.") )
254
+ expect( @request_sock ).to receive( :receive ).and_return( CZTop::Message.new( req ) )
239
255
 
240
256
  res = OneShotHandler.new( TEST_UUID, TEST_SEND_SPEC, TEST_RECV_SPEC ).run
241
257
 
@@ -246,9 +262,10 @@ describe Mongrel2::Handler, :db do
246
262
  expect( response.status ).to eq( 204 )
247
263
  end
248
264
 
265
+
249
266
  it "ignores disconnect notices by default" do
250
267
  req = make_json_request( :path => '@*', :body => {'type' => 'disconnect'} )
251
- expect( @request_sock ).to receive( :recv ).and_return( req )
268
+ expect( @request_sock ).to receive( :receive ).and_return( CZTop::Message.new( req ) )
252
269
 
253
270
  res = OneShotHandler.new( TEST_UUID, TEST_SEND_SPEC, TEST_RECV_SPEC ).run
254
271
 
@@ -258,6 +275,7 @@ describe Mongrel2::Handler, :db do
258
275
  expect( response ).to be_nil()
259
276
  end
260
277
 
278
+
261
279
  it "dispatches disconnect notices to the #handle_disconnect method" do
262
280
  disconnect_handler = Class.new( OneShotHandler ) do
263
281
  def handle_disconnect( request )
@@ -266,7 +284,7 @@ describe Mongrel2::Handler, :db do
266
284
  end
267
285
 
268
286
  req = make_json_request( :path => '@*', :body => {'type' => 'disconnect'} )
269
- expect( @request_sock ).to receive( :recv ).and_return( req )
287
+ expect( @request_sock ).to receive( :receive ).and_return( CZTop::Message.new( req ) )
270
288
 
271
289
  res = disconnect_handler.new( TEST_UUID, TEST_SEND_SPEC, TEST_RECV_SPEC ).run
272
290
 
@@ -276,10 +294,11 @@ describe Mongrel2::Handler, :db do
276
294
  expect( response ).to be_nil()
277
295
  end
278
296
 
297
+
279
298
  it "cancels async upload notices by default" do
280
299
  req = make_request( 'METHOD' => 'POST', :headers => {'x-mongrel2-upload-start' => 'uploadfile.XXX'} )
281
- expect( @request_sock ).to receive( :recv ).and_return( req )
282
- expect( @response_sock ).to receive( :send ).with( "#{TEST_UUID} 1:8, " )
300
+ expect( @request_sock ).to receive( :receive ).and_return( CZTop::Message.new( req ) )
301
+ expect( @response_sock ).to receive( :<< ).with( "#{TEST_UUID} 1:8, " )
283
302
 
284
303
  res = OneShotHandler.new( TEST_UUID, TEST_SEND_SPEC, TEST_RECV_SPEC ).run
285
304
 
@@ -288,6 +307,7 @@ describe Mongrel2::Handler, :db do
288
307
  expect( response ).to be_nil()
289
308
  end
290
309
 
310
+
291
311
  it "re-establishes its connection when told to restart" do
292
312
  res = OneShotHandler.new( TEST_UUID, TEST_SEND_SPEC, TEST_RECV_SPEC )
293
313
  original_conn = res.conn
@@ -295,6 +315,7 @@ describe Mongrel2::Handler, :db do
295
315
  expect( res.conn ).to_not equal( original_conn )
296
316
  end
297
317
 
318
+
298
319
  it "cleans any mongrel2 request spool files after sending a response" do
299
320
  spoolfile = Pathname.new( Dir.tmpdir + '/mongrel2.uskd8l1' )
300
321
  spoolfile.write( "Hi!" )
@@ -303,7 +324,7 @@ describe Mongrel2::Handler, :db do
303
324
  'x-mongrel2-upload-start' => spoolfile.basename,
304
325
  'x-mongrel2-upload-done' => spoolfile.basename
305
326
  })
306
- expect( @request_sock ).to receive( :recv ).and_return( req )
327
+ expect( @request_sock ).to receive( :receive ).and_return( CZTop::Message.new( req ) )
307
328
 
308
329
  res = OneShotHandler.new( TEST_UUID, TEST_SEND_SPEC, TEST_RECV_SPEC ).run
309
330
  request, response = res.transactions.first
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongrel2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.48.0
4
+ version: 0.49.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Granger
@@ -10,154 +10,159 @@ b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D+K9JW9DDs3Yjgv9k4h7YMhW5gftosd+NkNC/+Y2CkCAwEAAaN1MHMwCQYDVR0T
26
+ BAIwADALBgNVHQ8EBAMCBLAwHQYDVR0OBBYEFHKN/nkRusdqCJEuq3lgB3fJvyTg
27
+ MBwGA1UdEQQVMBOBEWdlZEBGYWVyaWVNVUQub3JnMBwGA1UdEgQVMBOBEWdlZEBG
28
+ YWVyaWVNVUQub3JnMA0GCSqGSIb3DQEBCwUAA4IBgQAPJzKiT0zBU7kpqe0aS2qb
29
+ FI0PJ4y5I8buU4IZGUD5NEt/N7pZNfOyBxkrZkXhS44Fp+xwBH5ebLbq/WY78Bqd
30
+ db0z6ZgW4LMYMpWFfbXsRbd9TU2f52L8oMAhxOvF7Of5qJMVWuFQ8FPagk2iHrdH
31
+ inYLQagqAF6goWTXgAJCdPd6SNeeSNqA6vlY7CV1Jh5kfNJJ6xu/CVij1GzCLu/5
32
+ DMOr26DBv+qLJRRC/2h34uX71q5QgeOyxvMg+7V3u/Q06DXyQ2VgeeqiwDFFpEH0
33
+ PFkdPO6ZqbTRcLfNH7mFgCBJjsfSjJrn0sPBlYyOXgCoByfZnZyrIMH/UY+lgQqS
34
+ 6Von1VDsfQm0eJh5zYZD64ZF86phSR7mUX3mXItwH04HrZwkWpvgd871DZVR3i1n
35
+ w8aNA5re5+Rt/Vvjxj5AcEnZnZiz5x959NaddQocX32Z1unHw44pzRNUur1GInfW
36
+ p4vpx2kUSFSAGjtCbDGTNV2AH8w9OU4xEmNz8c5lyoA=
32
37
  -----END CERTIFICATE-----
33
- date: 2017-01-16 00:00:00.000000000 Z
38
+ date: 2017-03-10 00:00:00.000000000 Z
34
39
  dependencies:
35
40
  - !ruby/object:Gem::Dependency
36
- name: sequel
41
+ name: cztop
37
42
  requirement: !ruby/object:Gem::Requirement
38
43
  requirements:
39
44
  - - "~>"
40
45
  - !ruby/object:Gem::Version
41
- version: '4.2'
46
+ version: '0.11'
42
47
  type: :runtime
43
48
  prerelease: false
44
49
  version_requirements: !ruby/object:Gem::Requirement
45
50
  requirements:
46
51
  - - "~>"
47
52
  - !ruby/object:Gem::Version
48
- version: '4.2'
53
+ version: '0.11'
49
54
  - !ruby/object:Gem::Dependency
50
- name: tnetstring
55
+ name: libxml-ruby
51
56
  requirement: !ruby/object:Gem::Requirement
52
57
  requirements:
53
58
  - - "~>"
54
59
  - !ruby/object:Gem::Version
55
- version: '0.3'
60
+ version: '2.7'
56
61
  type: :runtime
57
62
  prerelease: false
58
63
  version_requirements: !ruby/object:Gem::Requirement
59
64
  requirements:
60
65
  - - "~>"
61
66
  - !ruby/object:Gem::Version
62
- version: '0.3'
67
+ version: '2.7'
63
68
  - !ruby/object:Gem::Dependency
64
- name: yajl-ruby
69
+ name: loggability
65
70
  requirement: !ruby/object:Gem::Requirement
66
71
  requirements:
67
72
  - - "~>"
68
73
  - !ruby/object:Gem::Version
69
- version: '1.0'
74
+ version: '0.12'
70
75
  type: :runtime
71
76
  prerelease: false
72
77
  version_requirements: !ruby/object:Gem::Requirement
73
78
  requirements:
74
79
  - - "~>"
75
80
  - !ruby/object:Gem::Version
76
- version: '1.0'
81
+ version: '0.12'
77
82
  - !ruby/object:Gem::Dependency
78
- name: trollop
83
+ name: sequel
79
84
  requirement: !ruby/object:Gem::Requirement
80
85
  requirements:
81
86
  - - "~>"
82
87
  - !ruby/object:Gem::Version
83
- version: '2.0'
88
+ version: '4.2'
84
89
  type: :runtime
85
90
  prerelease: false
86
91
  version_requirements: !ruby/object:Gem::Requirement
87
92
  requirements:
88
93
  - - "~>"
89
94
  - !ruby/object:Gem::Version
90
- version: '2.0'
95
+ version: '4.2'
91
96
  - !ruby/object:Gem::Dependency
92
- name: sysexits
97
+ name: sqlite3
93
98
  requirement: !ruby/object:Gem::Requirement
94
99
  requirements:
95
100
  - - "~>"
96
101
  - !ruby/object:Gem::Version
97
- version: '1.1'
102
+ version: '1.3'
98
103
  type: :runtime
99
104
  prerelease: false
100
105
  version_requirements: !ruby/object:Gem::Requirement
101
106
  requirements:
102
107
  - - "~>"
103
108
  - !ruby/object:Gem::Version
104
- version: '1.1'
109
+ version: '1.3'
105
110
  - !ruby/object:Gem::Dependency
106
- name: rbczmq
111
+ name: sysexits
107
112
  requirement: !ruby/object:Gem::Requirement
108
113
  requirements:
109
114
  - - "~>"
110
115
  - !ruby/object:Gem::Version
111
- version: '1.7'
116
+ version: '1.1'
112
117
  type: :runtime
113
118
  prerelease: false
114
119
  version_requirements: !ruby/object:Gem::Requirement
115
120
  requirements:
116
121
  - - "~>"
117
122
  - !ruby/object:Gem::Version
118
- version: '1.7'
123
+ version: '1.1'
119
124
  - !ruby/object:Gem::Dependency
120
- name: loggability
125
+ name: tnetstring
121
126
  requirement: !ruby/object:Gem::Requirement
122
127
  requirements:
123
128
  - - "~>"
124
129
  - !ruby/object:Gem::Version
125
- version: '0.11'
130
+ version: '0.3'
126
131
  type: :runtime
127
132
  prerelease: false
128
133
  version_requirements: !ruby/object:Gem::Requirement
129
134
  requirements:
130
135
  - - "~>"
131
136
  - !ruby/object:Gem::Version
132
- version: '0.11'
137
+ version: '0.3'
133
138
  - !ruby/object:Gem::Dependency
134
- name: sqlite3
139
+ name: trollop
135
140
  requirement: !ruby/object:Gem::Requirement
136
141
  requirements:
137
142
  - - "~>"
138
143
  - !ruby/object:Gem::Version
139
- version: '1.3'
144
+ version: '2.0'
140
145
  type: :runtime
141
146
  prerelease: false
142
147
  version_requirements: !ruby/object:Gem::Requirement
143
148
  requirements:
144
149
  - - "~>"
145
150
  - !ruby/object:Gem::Version
146
- version: '1.3'
151
+ version: '2.0'
147
152
  - !ruby/object:Gem::Dependency
148
- name: libxml-ruby
153
+ name: yajl-ruby
149
154
  requirement: !ruby/object:Gem::Requirement
150
155
  requirements:
151
156
  - - "~>"
152
157
  - !ruby/object:Gem::Version
153
- version: '2.7'
158
+ version: '1.0'
154
159
  type: :runtime
155
160
  prerelease: false
156
161
  version_requirements: !ruby/object:Gem::Requirement
157
162
  requirements:
158
163
  - - "~>"
159
164
  - !ruby/object:Gem::Version
160
- version: '2.7'
165
+ version: '1.0'
161
166
  - !ruby/object:Gem::Dependency
162
167
  name: hoe-mercurial
163
168
  requirement: !ruby/object:Gem::Requirement
@@ -301,7 +306,6 @@ extra_rdoc_files:
301
306
  - History.rdoc
302
307
  - Manifest.txt
303
308
  - README.rdoc
304
- - examples/README.txt
305
309
  files:
306
310
  - ".autotest"
307
311
  - ".gemtest"
@@ -313,24 +317,8 @@ files:
313
317
  - README.rdoc
314
318
  - Rakefile
315
319
  - bin/m2sh.rb
316
- - data/mongrel2/bootstrap.html
317
- - data/mongrel2/config.rb.in
318
320
  - data/mongrel2/config.sql
319
- - data/mongrel2/css/master.css
320
- - data/mongrel2/index.html.in
321
- - data/mongrel2/js/websock-test.js
322
321
  - data/mongrel2/mimetypes.sql
323
- - data/mongrel2/websock-test.html
324
- - examples/Procfile
325
- - examples/README.txt
326
- - examples/async-upload.rb
327
- - examples/config.rb
328
- - examples/helloworld-handler.rb
329
- - examples/request-dumper.rb
330
- - examples/request-dumper.tmpl
331
- - examples/run
332
- - examples/sendfile.rb
333
- - examples/ws-echo.rb
334
322
  - lib/mongrel2.rb
335
323
  - lib/mongrel2/config.rb
336
324
  - lib/mongrel2/config/directory.rb
@@ -410,7 +398,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
410
398
  version: '0'
411
399
  requirements: []
412
400
  rubyforge_project:
413
- rubygems_version: 2.5.1
401
+ rubygems_version: 2.6.8
414
402
  signing_key:
415
403
  specification_version: 4
416
404
  summary: Ruby-Mongrel2 is a complete Ruby connector for Mongrel2[http://mongrel2.org/]