mongrel2 0.48.0 → 0.49.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6786f4a00423675914ad7830e93d7914890817b1
4
- data.tar.gz: 35b28c12214e875845894b4b1ec1dd812826cd4b
3
+ metadata.gz: 944abee18512b2a14ea074675313be9c301e3960
4
+ data.tar.gz: d46b4b9b56a054bb195f4a42bf14b08f69164768
5
5
  SHA512:
6
- metadata.gz: 99f3d11f3f3479494dd1659e6081a43cacfc6ec38252b81614ec2a19be448f7eada8a0818a5d45a44b5de00295a4d9594156b20ae63434eae75c33cf92d5e074
7
- data.tar.gz: a9852093ada84552f79d1a5d5bdfea3cd04213bae5889edb6bf9d15ef46a895cda9ccbeb68013ce3da8472620427ee662a7cedf1bbac01aa7686ca5c45d5f6a2
6
+ metadata.gz: 5c4efad71c6dde2c3a8b15951c5651c6ac4bf2e37ff157b4b6f385f2ab0b0c0c9ee31714ef50f3926e987d079416c218b0aca38a3304624e787cdfaf7b201c26
7
+ data.tar.gz: eef053a14975b06e55e4ce1c459d56adbf5592a4668a4c2571f6cb2d47789211497ca283ddbe72369325abd761c175f6b755734c18394222467663fab2dae459
Binary file
data.tar.gz.sig CHANGED
Binary file
data/ChangeLog CHANGED
@@ -1,8 +1,16 @@
1
1
  2016-11-23 Mahlon E. Smith <mahlon@martini.nu>
2
2
 
3
+ * .hgtags:
4
+ Added tag v0.47.0 for changeset 3298fb41de78
5
+ [b01f4b4e8c2f] [tip]
6
+
7
+ * .hgsigs:
8
+ Added signature for changeset c4ae80fe8067
9
+ [3298fb41de78] [v0.47.0]
10
+
3
11
  * History.rdoc, lib/mongrel2.rb:
4
12
  Bump version, update History.
5
- [c4ae80fe8067] [tip]
13
+ [c4ae80fe8067]
6
14
 
7
15
  * lib/mongrel2/handler.rb, spec/mongrel2/handler_spec.rb:
8
16
  Rather than waiting for GC to free up a descriptor, close spooled
@@ -13,7 +21,7 @@
13
21
 
14
22
  * .hgtags:
15
23
  Added tag v0.46.0 for changeset e7c165fb6bb2
16
- [7f3c8162e5ef]
24
+ [7f3c8162e5ef] [github/master]
17
25
 
18
26
  * .hgsigs:
19
27
  Added signature for changeset a28294965462
@@ -1,3 +1,10 @@
1
+ == v0.49.0 [2017-03-10] Michael Granger <ged@FaerieMUD.org>
2
+
3
+ Enhancements:
4
+
5
+ - Use the CZTop library instead of rbczmq for ZeroMQ sockets.
6
+
7
+
1
8
  == v0.48.0 [2017-01-16] Mahlon E. Smith <mahlon@martini.nu>
2
9
 
3
10
  Housekeeping:
@@ -8,24 +8,8 @@ Manifest.txt
8
8
  README.rdoc
9
9
  Rakefile
10
10
  bin/m2sh.rb
11
- data/mongrel2/bootstrap.html
12
- data/mongrel2/config.rb.in
13
11
  data/mongrel2/config.sql
14
- data/mongrel2/css/master.css
15
- data/mongrel2/index.html.in
16
- data/mongrel2/js/websock-test.js
17
12
  data/mongrel2/mimetypes.sql
18
- data/mongrel2/websock-test.html
19
- examples/Procfile
20
- examples/README.txt
21
- examples/async-upload.rb
22
- examples/config.rb
23
- examples/helloworld-handler.rb
24
- examples/request-dumper.rb
25
- examples/request-dumper.tmpl
26
- examples/run
27
- examples/sendfile.rb
28
- examples/ws-echo.rb
29
13
  lib/mongrel2.rb
30
14
  lib/mongrel2/config.rb
31
15
  lib/mongrel2/config/directory.rb
@@ -155,10 +155,6 @@ and generate the API documentation.
155
155
  There are two other Mongrel2 Ruby libraries, +m2r+ +rack-mongrel2+.
156
156
  This implementation differs from them in several ways:
157
157
 
158
- * It uses a C extension for 0MQ (rbczmq) instead of the FFI one. If you
159
- strongly prefer the FFI library, both of the other Mongrel2 libraries use
160
- it, so you'll want to stick to one of them.
161
-
162
158
  * It doesn't come with a Rack handler, or Rails examples, or anything too
163
159
  fancy. I intend to build my own webby framework bits around Mongrel2, and
164
160
  I thought maybe someone else might want to as well. If you don't, well
data/Rakefile CHANGED
@@ -25,15 +25,15 @@ hoespec = Hoe.spec 'mongrel2' do
25
25
 
26
26
  self.developer 'Michael Granger', 'ged@FaerieMUD.org'
27
27
 
28
+ self.dependency 'cztop', '~> 0.11'
29
+ self.dependency 'libxml-ruby', '~> 2.7'
30
+ self.dependency 'loggability', '~> 0.12'
28
31
  self.dependency 'sequel', '~> 4.2'
32
+ self.dependency 'sqlite3', '~> 1.3'
33
+ self.dependency 'sysexits', '~> 1.1'
29
34
  self.dependency 'tnetstring', '~> 0.3'
30
- self.dependency 'yajl-ruby', '~> 1.0'
31
35
  self.dependency 'trollop', '~> 2.0'
32
- self.dependency 'sysexits', '~> 1.1'
33
- self.dependency 'rbczmq', '~> 1.7'
34
- self.dependency 'loggability', '~> 0.11'
35
- self.dependency 'sqlite3', '~> 1.3'
36
- self.dependency 'libxml-ruby', '~> 2.7'
36
+ self.dependency 'yajl-ruby', '~> 1.0'
37
37
 
38
38
  self.dependency 'amalgalite', '~> 1.5', :developer
39
39
  self.dependency 'configurability', '~> 3.1', :developer
@@ -76,7 +76,7 @@ if File.directory?( '.hg' )
76
76
  end
77
77
 
78
78
  task :gemspec => GEMSPEC
79
- file GEMSPEC => __FILE__
79
+ file GEMSPEC => [ __FILE__, 'Manifest.txt' ]
80
80
  task GEMSPEC do |task|
81
81
  spec = $hoespec.spec
82
82
  spec.files.delete( '.gemtest' )
@@ -1,11 +1,8 @@
1
1
  # -*- ruby -*-
2
2
  #encoding: utf-8
3
3
 
4
- # Ensure this is used instead of 'zmq' if it's also installed
5
- gem 'rbczmq'
6
-
7
4
  require 'loggability'
8
- require 'zmq'
5
+ require 'cztop'
9
6
 
10
7
  #
11
8
  # A Mongrel2 connector and configuration library for Ruby.
@@ -25,10 +22,10 @@ module Mongrel2
25
22
  abort "\n\n>>> Mongrel2 requires Ruby 2.2 or later. <<<\n\n" if RUBY_VERSION < '2.2.0'
26
23
 
27
24
  # Library version constant
28
- VERSION = '0.48.0'
25
+ VERSION = '0.49.0'
29
26
 
30
27
  # Version-control revision constant
31
- REVISION = %q$Revision: 50bb8c488bc4 $
28
+ REVISION = %q$Revision: e2508eadb52d $
32
29
 
33
30
 
34
31
  require 'mongrel2/constants'
@@ -44,20 +41,6 @@ module Mongrel2
44
41
  end
45
42
 
46
43
 
47
- # ZMQ::Context (lazy-loaded)
48
- @zmq_ctx = nil
49
-
50
- ### Fetch the ZMQ::Context for sockets, creating it if necessary.
51
- def self::zmq_context
52
- if @zmq_ctx.nil?
53
- self.log.info "Using 0MQ %d.%d.%d" % ZMQ.version
54
- @zmq_ctx = ZMQ::Context.new
55
- end
56
-
57
- return @zmq_ctx
58
- end
59
-
60
-
61
44
  require 'mongrel2/exceptions'
62
45
  require 'mongrel2/connection'
63
46
  require 'mongrel2/handler'
@@ -72,11 +55,3 @@ module Mongrel2
72
55
  end # module Mongrel2
73
56
 
74
57
 
75
- # Workaround for rbzmq <= 2.3.0
76
- unless defined?( ZMQ::Error )
77
- module ZMQ
78
- Error = ::RuntimeError
79
- end
80
- end
81
-
82
-
@@ -2,7 +2,7 @@
2
2
  #encoding: utf-8
3
3
 
4
4
  require 'socket'
5
- require 'zmq'
5
+ require 'cztop'
6
6
  require 'yajl'
7
7
  require 'digest/sha1'
8
8
  require 'loggability'
@@ -66,17 +66,14 @@ class Mongrel2::Connection
66
66
 
67
67
  ### Establish both connections to the Mongrel2 server.
68
68
  def connect
69
- ctx = Mongrel2.zmq_context
70
- self.log.debug "0mq Context is: %p" % [ ctx ]
71
-
72
69
  self.log.info "Connecting PULL request socket (%s)" % [ self.sub_addr ]
73
- @request_sock = ctx.socket( :PULL )
74
- @request_sock.linger = 0
70
+ @request_sock = CZTop::Socket::PULL.new
71
+ @request_sock.options.linger = 0
75
72
  @request_sock.connect( self.sub_addr )
76
73
 
77
74
  self.log.info "Connecting PUB response socket (%s)" % [ self.pub_addr ]
78
- @response_sock = ctx.socket( :PUB )
79
- @response_sock.linger = 0
75
+ @response_sock = CZTop::Socket::PUB.new
76
+ @response_sock.options.linger = 0
80
77
  @response_sock.connect( self.pub_addr )
81
78
  end
82
79
 
@@ -104,7 +101,8 @@ class Mongrel2::Connection
104
101
  self.check_closed
105
102
 
106
103
  self.log.debug "Fetching next request (PULL)"
107
- data = self.request_sock.recv or raise( ZMQ.error || 'unknown error' )
104
+ message = self.request_sock.receive
105
+ data = message.pop
108
106
  self.log.debug " got %d bytes of %s request data" % [ data.bytesize, data.encoding.name ]
109
107
  return data
110
108
  end
@@ -124,7 +122,7 @@ class Mongrel2::Connection
124
122
  header = "%s %d:%s," % [ sender_id, conn_id.to_s.length, conn_id ]
125
123
  buf = header + ' ' + data
126
124
  self.log.debug "Sending response (PUB)"
127
- self.response_sock.send( buf )
125
+ self.response_sock << buf
128
126
  self.log.debug " done with send (%d bytes)" % [ buf.bytesize ]
129
127
  end
130
128
 
@@ -136,7 +134,7 @@ class Mongrel2::Connection
136
134
  self.log.debug "Sending response with %s extended reply (PUB)"
137
135
  header = "%s %d:X %s," % [ sender_id, conn_id.to_s.length + 2, conn_id ]
138
136
  buf = header + ' ' + TNetstring.dump( [response_type] + data )
139
- self.response_sock.send( buf )
137
+ self.response_sock << buf
140
138
  self.log.debug " done with send (%d bytes)" % [ buf.bytesize ]
141
139
  end
142
140
 
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/ruby
2
2
 
3
- require 'zmq'
3
+ require 'cztop'
4
4
  require 'yajl'
5
5
  require 'pathname'
6
6
  require 'tnetstring'
@@ -27,9 +27,8 @@ class Mongrel2::Control
27
27
  ### Create a new control port object using the current configuration.
28
28
  def initialize( port=DEFAULT_PORT )
29
29
  check_port( port )
30
- @ctx = Mongrel2.zmq_context
31
- @socket = @ctx.socket( :REQ )
32
- @socket.linger = 0
30
+ @socket = CZTop::Socket::REQ.new
31
+ @socket.options.linger = 0
33
32
  @socket.connect( port.to_s )
34
33
  end
35
34
 
@@ -172,11 +171,11 @@ class Mongrel2::Control
172
171
  def request( command, options={} )
173
172
  msg = TNetstring.dump([ command, options ])
174
173
  self.log.debug "Request: %p" % [ msg ]
175
- self.socket.send( msg )
174
+ self.socket << msg
176
175
 
177
- response = self.socket.recv
176
+ response = self.socket.receive
178
177
  self.log.debug "Response: %p" % [ response ]
179
- return unpack_response( response )
178
+ return unpack_response( response.pop )
180
179
  end
181
180
 
182
181
 
@@ -1,7 +1,7 @@
1
1
  #-*- ruby -*-
2
2
  #encoding: utf-8
3
3
 
4
- require 'zmq'
4
+ require 'cztop'
5
5
  require 'loggability'
6
6
 
7
7
  require 'mongrel2' unless defined?( Mongrel2 )
@@ -135,8 +135,16 @@ class Mongrel2::Handler
135
135
  ### Create a new instance of the handler with the specified +app_id+, +send_spec+,
136
136
  ### and +recv_spec+.
137
137
  def initialize( app_id, send_spec, recv_spec ) # :notnew:
138
- @app_id = app_id
139
- @conn = Mongrel2::Connection.new( app_id, send_spec, recv_spec )
138
+ @app_id = app_id
139
+ @conn = Mongrel2::Connection.new( app_id, send_spec, recv_spec )
140
+ # @self_pipe = CZTop::Socket::PAIR.new( 'inproc://signal-handler' )
141
+
142
+ @self_pipe = {
143
+ reader: CZTop::Socket::PAIR.new( '@inproc://signal-handler' ),
144
+ writer: CZTop::Socket::PAIR.new( '>inproc://signal-handler' )
145
+ }
146
+
147
+ @poller = CZTop::Poller.new( @conn.request_sock, @self_pipe[:reader] )
140
148
 
141
149
  Thread.main[:signal_queue] = []
142
150
  end
@@ -156,6 +164,7 @@ class Mongrel2::Handler
156
164
  ### Run the handler.
157
165
  def run
158
166
  self.log.info "Starting up %p" % [ self ]
167
+
159
168
  self.set_signal_handlers
160
169
  self.start_accepting_requests
161
170
 
@@ -164,7 +173,6 @@ class Mongrel2::Handler
164
173
  self.restore_signal_handlers
165
174
  self.log.info "Done: %p" % [ self ]
166
175
  @conn.close
167
- Mongrel2.zmq_context.close if Mongrel2.zmq_context.respond_to?( :close )
168
176
  end
169
177
 
170
178
 
@@ -222,6 +230,9 @@ class Mongrel2::Handler
222
230
  self.log.info "Restarting"
223
231
  old_conn = @conn
224
232
  @conn = @conn.dup
233
+
234
+ @poller = CZTop::Poller.new( @conn.request_sock, @self_pipe[:reader] )
235
+
225
236
  self.log.debug " conn %p -> %p" % [ old_conn, @conn ]
226
237
  old_conn.close
227
238
  end
@@ -229,26 +240,34 @@ class Mongrel2::Handler
229
240
 
230
241
  ### Start a loop, accepting a request and handling it.
231
242
  def start_accepting_requests
243
+ self.log.info "Starting the request loop."
232
244
  until @conn.closed?
233
- ZMQ.select([ @conn.request_sock ])
234
- self.accept_request unless @conn.closed?
245
+ begin
246
+ if event = @poller.wait
247
+ case event.socket
248
+ when @conn.request_sock
249
+ req = @conn.receive
250
+ self.accept_request( req ) unless @conn.closed?
251
+ when @self_pipe[:reader]
252
+ @self_pipe[:reader].wait
253
+ self.process_signal_queue
254
+ else
255
+ self.log.warn "Got unhandled poller event: %p" % [ event ]
256
+ end
257
+ end
258
+ rescue Errno::EAGAIN
259
+ # self.log.debug "Got EAGAIN, retrying."
260
+ rescue Interrupt
261
+ # self.log.debug "Got an Interrupt; retrying."
262
+ end
235
263
  end
236
- rescue ZMQ::Error => err
237
- self.process_signal_queue
238
-
239
- unless @conn.closed?
240
- self.log.error "%p while accepting requests: %s" % [ err.class, err.message ]
241
- self.log.debug { err.backtrace.join("\n ") }
242
264
 
243
- # Restart the method
244
- retry
245
- end
265
+ self.log.debug "Done accepting requests."
246
266
  end
247
267
 
248
268
 
249
269
  ### Read a request from the connection and dispatch it.
250
- def accept_request
251
- req = @conn.receive
270
+ def accept_request( req )
252
271
  self.log.info( req.inspect )
253
272
  res = self.dispatch_request( req )
254
273
 
@@ -414,11 +433,23 @@ class Mongrel2::Handler
414
433
  # be handled, override #set_signal_handlers with an empty method.
415
434
  #
416
435
 
436
+ ### Wake up the handler when a signal needs to be processed.
437
+ def wake_up
438
+ $stderr.puts "Waking up the signal handler"
439
+ @self_pipe[ :writer ].signal( 0 )
440
+ $stderr.puts "Done sending the wakeup."
441
+ end
442
+
443
+
417
444
  ### Set up signal handlers for common signals that will shut down, restart, etc.
418
445
  def set_signal_handlers
419
446
  self.log.debug "Setting up deferred signal handlers."
420
447
  QUEUE_SIGS.each do |sig|
421
- Signal.trap( sig ) { Thread.main[:signal_queue] << sig }
448
+ Signal.trap( sig ) do
449
+ Thread.main[:signal_queue] << sig
450
+ self.wake_up
451
+ $stderr.puts "Done handling the signal."
452
+ end
422
453
  end
423
454
  end
424
455
 
@@ -440,6 +471,7 @@ class Mongrel2::Handler
440
471
  end
441
472
  end
442
473
 
474
+
443
475
  ### Handle any queued signals.
444
476
  def process_signal_queue
445
477
  # Look for any signals that arrived and handle them
@@ -2,6 +2,7 @@
2
2
 
3
3
  require_relative '../helpers'
4
4
 
5
+ require 'ostruct'
5
6
  require 'mongrel2'
6
7
  require 'mongrel2/connection'
7
8
 
@@ -18,16 +19,9 @@ describe Mongrel2::Connection do
18
19
 
19
20
  # Ensure 0MQ never actually gets called
20
21
  before( :each ) do
21
- @ctx = double( "0mq context" )
22
- Mongrel2.instance_variable_set( :@zmq_ctx, @ctx )
23
-
24
22
  @conn = Mongrel2::Connection.new( TEST_UUID, TEST_SEND_SPEC, TEST_RECV_SPEC )
25
23
  end
26
24
 
27
- after( :each ) do
28
- Mongrel2.instance_variable_set( :@zmq_ctx, nil )
29
- end
30
-
31
25
 
32
26
  it "doesn't connect to the endpoints when it's created" do
33
27
  expect( @conn.instance_variable_get( :@request_sock ) ).to be_nil()
@@ -35,16 +29,16 @@ describe Mongrel2::Connection do
35
29
  end
36
30
 
37
31
  it "connects to the endpoints specified on demand" do
38
- request_sock = double( "request socket" )
39
- response_sock = double( "response socket" )
32
+ request_sock = double( "request socket", options: OpenStruct.new )
33
+ response_sock = double( "response socket", options: OpenStruct.new )
40
34
 
41
- expect( @ctx ).to receive( :socket ).with( :PULL ).and_return( request_sock )
42
- expect( request_sock ).to receive( :linger= ).with( 0 )
35
+ expect( CZTop::Socket::PULL ).to receive( :new ).and_return( request_sock )
36
+ expect( request_sock.options ).to receive( :linger= ).with( 0 )
43
37
  expect( request_sock ).to receive( :connect ).with( TEST_SEND_SPEC )
44
38
 
45
- expect( @ctx ).to receive( :socket ).with( :PUB ).and_return( response_sock )
46
- expect( response_sock ).to receive( :linger= ).with( 0 )
47
- expect( response_sock ).to_not receive( :identity= )
39
+ expect( CZTop::Socket::PUB ).to receive( :new ).and_return( response_sock )
40
+ expect( response_sock.options ).to receive( :linger= ).with( 0 )
41
+ expect( response_sock.options ).to_not receive( :identity= )
48
42
  expect( response_sock ).to receive( :connect ).with( TEST_RECV_SPEC )
49
43
 
50
44
  expect( @conn.request_sock ).to eq( request_sock )
@@ -58,11 +52,11 @@ describe Mongrel2::Connection do
58
52
  context "after a connection has been established" do
59
53
 
60
54
  before( :each ) do
61
- @request_sock = double( "request socket", :linger= => nil, :connect => nil )
62
- @response_sock = double( "response socket", :linger= => nil, :connect => nil )
55
+ @request_sock = double( "request socket", :options => OpenStruct.new, :connect => nil )
56
+ @response_sock = double( "response socket", :options => OpenStruct.new, :connect => nil )
63
57
 
64
- allow( @ctx ).to receive( :socket ).with( :PULL ).and_return( @request_sock )
65
- allow( @ctx ).to receive( :socket ).with( :PUB ).and_return( @response_sock )
58
+ allow( CZTop::Socket::PULL ).to receive( :new ).and_return( @request_sock )
59
+ allow( CZTop::Socket::PUB ).to receive( :new ).and_return( @response_sock )
66
60
 
67
61
  @conn.connect
68
62
  end
@@ -87,10 +81,10 @@ describe Mongrel2::Connection do
87
81
  end
88
82
 
89
83
  it "doesn't keep its request and response sockets when duped" do
90
- request_sock2 = double( "request socket", :linger= => nil, :connect => nil )
91
- response_sock2 = double( "response socket", :linger= => nil, :connect => nil )
92
- allow( @ctx ).to receive( :socket ).with( :PULL ).and_return( request_sock2 )
93
- allow( @ctx ).to receive( :socket ).with( :PUB ).and_return( response_sock2 )
84
+ request_sock2 = double( "request socket", :options => OpenStruct.new, :connect => nil )
85
+ response_sock2 = double( "response socket", :options => OpenStruct.new, :connect => nil )
86
+ allow( CZTop::Socket::PULL ).to receive( :new ).and_return( request_sock2 )
87
+ allow( CZTop::Socket::PUB ).to receive( :new ).and_return( response_sock2 )
94
88
 
95
89
  duplicate = @conn.dup
96
90
 
@@ -109,72 +103,56 @@ describe Mongrel2::Connection do
109
103
  end
110
104
 
111
105
  it "can read raw request messages off of the request_sock" do
112
- expect( @request_sock ).to receive( :recv ).and_return( "the data" )
106
+ expect( @request_sock ).to receive( :receive ).and_return( CZTop::Message.new( "the data" ) )
113
107
  expect( @conn.recv ).to eq( "the data" )
114
108
  end
115
109
 
116
110
  it "can read request messages off of the request_sock as Mongrel2::Request objects" do
117
111
  msg = make_request()
118
- expect( @request_sock ).to receive( :recv ).and_return( msg )
112
+ expect( @request_sock ).to receive( :receive ).and_return( CZTop::Message.new( msg ) )
119
113
  expect( @conn.receive ).to be_a( Mongrel2::Request )
120
114
  end
121
115
 
122
- it "handles a socket error while receiving" do
123
- expect( @request_sock ).to receive( :recv ).and_return( nil )
124
- expect( ZMQ ).to receive( :error ).and_return( ZMQ::Error.new("something bad happened") )
125
- expect {
126
- @conn.receive
127
- }.to raise_error( ZMQ::Error, 'something bad happened' )
128
- end
129
-
130
- it "handles a socket error that doesn't set an error message while receiving" do
131
- expect( @request_sock ).to receive( :recv ).and_return( nil )
132
- expect( ZMQ ).to receive( :error ).and_return( nil )
133
- expect {
134
- @conn.receive
135
- }.to raise_error( RuntimeError, 'unknown error' )
136
- end
137
-
138
116
  it "can write raw response messages with a TNetString header onto the response_sock" do
139
- expect( @response_sock ).to receive( :send ).with( "#{TEST_UUID} 1:8, the data" )
117
+ expect( @response_sock ).to receive( :<< ).with( "#{TEST_UUID} 1:8, the data" )
140
118
  @conn.send( TEST_UUID, 8, "the data" )
141
119
  end
142
120
 
143
121
  it "can write Mongrel2::Responses to the response_sock" do
144
- expect( @response_sock ).to receive( :send ).with( "#{TEST_UUID} 1:8, the data" )
122
+ expect( @response_sock ).to receive( :<< ).with( "#{TEST_UUID} 1:8, the data" )
145
123
 
146
124
  response = Mongrel2::Response.new( TEST_UUID, 8, 'the data' )
147
125
  @conn.reply( response )
148
126
  end
149
127
 
150
128
  it "can write raw response messages to more than one conn_id at the same time" do
151
- expect( @response_sock ).to receive( :send ).
129
+ expect( @response_sock ).to receive( :<< ).
152
130
  with( "#{TEST_UUID} 15:8 16 44 45 1833, the data" )
153
131
  @conn.broadcast( TEST_UUID, [8, 16, 44, 45, 1833], 'the data' )
154
132
  end
155
133
 
156
134
  it "can write raw response messages to more than one conn_id at the same time" do
157
- expect( @response_sock ).to receive( :send ).
135
+ expect( @response_sock ).to receive( :<< ).
158
136
  with( "#{TEST_UUID} 15:8 16 44 45 1833, the data" )
159
137
  @conn.broadcast( TEST_UUID, [8, 16, 44, 45, 1833], 'the data' )
160
138
  end
161
139
 
162
140
  it "can write an extended response message" do
163
- expect( @response_sock ).to receive( :send ).
141
+ expect( @response_sock ).to receive( :<< ).
164
142
  with( "#{TEST_UUID} 3:X 8, 27:8:sendfile,12:the_data.txt,]" )
165
143
  @conn.send_extended( TEST_UUID, 8, :sendfile, "the_data.txt" )
166
144
  end
167
145
 
168
146
  it "can broadcast an extended response message" do
169
- expect( @response_sock ).to receive( :send ).
147
+ expect( @response_sock ).to receive( :<< ).
170
148
  with( "#{TEST_UUID} 9:X 8 16 32, 27:8:sendfile,12:the_data.txt,]" )
171
149
  @conn.broadcast_extended( TEST_UUID, [8,16,32], :sendfile, "the_data.txt" )
172
150
  end
173
151
 
174
152
  it "can write a Mongrel2::Response with extended reply" do
175
- expect( @response_sock ).to receive( :send ).
153
+ expect( @response_sock ).to receive( :<< ).
176
154
  with( "#{TEST_UUID} 1:8, " )
177
- expect( @response_sock ).to receive( :send ).
155
+ expect( @response_sock ).to receive( :<< ).
178
156
  with( "#{TEST_UUID} 3:X 8, 27:8:sendfile,12:the_data.txt,]" )
179
157
 
180
158
  response = Mongrel2::Response.new( TEST_UUID, 8, '' )
@@ -185,14 +163,14 @@ describe Mongrel2::Connection do
185
163
  end
186
164
 
187
165
  it "can tell the connection a request or a response was from to close" do
188
- expect( @response_sock ).to receive( :send ).with( "#{TEST_UUID} 1:8, " )
166
+ expect( @response_sock ).to receive( :<< ).with( "#{TEST_UUID} 1:8, " )
189
167
 
190
168
  response = Mongrel2::Response.new( TEST_UUID, 8 )
191
169
  @conn.reply_close( response )
192
170
  end
193
171
 
194
172
  it "can broadcast a close to multiple connection IDs" do
195
- expect( @response_sock ).to receive( :send ).with( "#{TEST_UUID} 15:8 16 44 45 1833, " )
173
+ expect( @response_sock ).to receive( :<< ).with( "#{TEST_UUID} 15:8 16 44 45 1833, " )
196
174
  @conn.broadcast_close( TEST_UUID, [8, 16, 44, 45, 1833] )
197
175
  end
198
176