faye-websocket 0.10.7 → 0.10.8

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of faye-websocket might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 04b914f093bd2e483eba87b081b1731e96145a9c
4
- data.tar.gz: d11b22297ff5ce1fd4f1a6f32cb54cb818fb10f3
2
+ SHA256:
3
+ metadata.gz: 628a479aab315c020df8a057cf2533e2b2572b92cd81cdaff4006eae24ac3200
4
+ data.tar.gz: 0df9233725d24bf5ce905090b99271bcd4f47d598eb98912d9eef810cec950be
5
5
  SHA512:
6
- metadata.gz: 9fab557063c51f4e3d4332ec395e82d76b6ce73fe6e877f594eb280c85d1fb5d7d45cd9af8b7ebeb5064d4aa480fb364768f02d0d3fbd8ba0edff08009e53257
7
- data.tar.gz: ca55257cb5654ef76d5da7c7d04f1501914ed986a8cfba664657765be226e21d3eb32185163844392fda9fd63a8d39cf93505a3271ccacd7485ffbb2c7732022
6
+ metadata.gz: 439970962dd6c8198885d242d3165dde1f1d41c81e5b0ac2f11be97fa45e8f73d89cf94a97ef2f53521515a048bd2300357396645261609c63905a82cc7af55e
7
+ data.tar.gz: 8dffa7a809059080bf01c07104936c7b25dafc40e7a9e57782438c685ed9c686c2771d7d784863861395b75a4887e9ef5358b325007fa5200a5c4819903fc84f
@@ -1,161 +1,172 @@
1
+ ### 0.10.8 / 2019-06-10
2
+
3
+ - In the case of a close timeout, don't block on waiting for writing to the
4
+ socket to complete
5
+ - Fix a race condition that caused a timeout not to be cancelled immediately
6
+ when the WebSocket is closed
7
+
1
8
  ### 0.10.7 / 2017-02-22
2
9
 
3
- * Emit an error if `EventMachine::Connection#unbind` is called with an error
10
+ - Emit an error if `EventMachine::Connection#unbind` is called with an error
4
11
 
5
12
  ### 0.10.6 / 2017-01-22
6
13
 
7
- * Forcibly close the I/O stream after a timeout if the peer does not respond
14
+ - Forcibly close the I/O stream after a timeout if the peer does not respond
8
15
  after calling `close()`
9
16
 
10
17
  ### 0.10.5 / 2016-11-12
11
18
 
12
- * Set the SNI hostname when making secure requests
19
+ - Set the SNI hostname when making secure requests
13
20
 
14
21
  ### 0.10.4 / 2016-05-20
15
22
 
16
- * Amend warnings issued when running with -W2
23
+ - Amend warnings issued when running with -W2
17
24
 
18
25
  ### 0.10.3 / 2016-02-24
19
26
 
20
- * Use `PATH_INFO` and `QUERY_STRING` rather than the non-standard `REQUEST_URI` from the Rack env
27
+ - Use `PATH_INFO` and `QUERY_STRING` rather than the non-standard `REQUEST_URI`
28
+ from the Rack env
21
29
 
22
30
  ### 0.10.2 / 2015-11-26
23
31
 
24
- * Fix the `headers` and `status` methods on `Client`, which were broken in the
32
+ - Fix the `headers` and `status` methods on `Client`, which were broken in the
25
33
  last release
26
34
 
27
35
  ### 0.10.1 / 2015-11-06
28
36
 
29
- * Make sure errors can be safely emitted if creating the driver fails
30
- * Prevent a race condition when binding `EM.attach` to the socket
37
+ - Make sure errors can be safely emitted if creating the driver fails
38
+ - Prevent a race condition when binding `EM.attach` to the socket
31
39
 
32
40
  ### 0.10.0 / 2015-07-08
33
41
 
34
- * Add the standard `code` and `reason` parameters to the `close` method
42
+ - Add the standard `code` and `reason` parameters to the `close` method
35
43
 
36
44
  ### 0.9.2 / 2014-12-21
37
45
 
38
- * Only emit `error` once, and don't emit it after `close`
46
+ - Only emit `error` once, and don't emit it after `close`
39
47
 
40
48
  ### 0.9.1 / 2014-12-18
41
49
 
42
- * Check that all options to the WebSocket constructor are recognized
50
+ - Check that all options to the WebSocket constructor are recognized
43
51
 
44
52
  ### 0.9.0 / 2014-12-13
45
53
 
46
- * Allow protocol extensions to be passed into websocket-extensions
54
+ - Allow protocol extensions to be passed into websocket-extensions
47
55
 
48
56
  ### 0.8.0 / 2014-11-08
49
57
 
50
- * Support connections via HTTP proxies
58
+ - Support connections via HTTP proxies
51
59
 
52
60
  ### 0.7.5 / 2014-10-04
53
61
 
54
- * Allow sockets to be closed when they are in any state other than `CLOSED`
62
+ - Allow sockets to be closed when they are in any state other than `CLOSED`
55
63
 
56
64
  ### 0.7.4 / 2014-07-06
57
65
 
58
- * Stop using `define_method` to implement `Event` properties, since it blows the method cache
59
- * Stop setup errors masking URI errors in `Client#initialize`
60
- * Make the Goliath adapter compatible with goliath-1.0.4.
66
+ - Stop using `define_method` to implement `Event` properties, since it blows the
67
+ method cache
68
+ - Stop setup errors masking URI errors in `Client#initialize`
69
+ - Make the Goliath adapter compatible with goliath-1.0.4.
61
70
 
62
71
  ### 0.7.3 / 2014-04-24
63
72
 
64
- * Remove an unneeded method override in the `WebSocket` class
73
+ - Remove an unneeded method override in the `WebSocket` class
65
74
 
66
75
  ### 0.7.2 / 2013-12-29
67
76
 
68
- * Fix WebSocket detection in cases where the web server does not produce an `env`
77
+ - Fix WebSocket detection in cases where the web server does not produce an
78
+ `env`
69
79
 
70
80
  ### 0.7.1 / 2013-12-03
71
81
 
72
- * Support the `max_length` websocket-driver option
73
- * Expose a `message` property on `error` events
82
+ - Support the `max_length` websocket-driver option
83
+ - Expose a `message` property on `error` events
74
84
 
75
85
  ### 0.7.0 / 2013-09-09
76
86
 
77
- * Allow the server to send custom headers with EventSource responses
87
+ - Allow the server to send custom headers with EventSource responses
78
88
 
79
89
  ### 0.6.3 / 2013-08-04
80
90
 
81
- * Stop implicitly depending on Rack 1.4
91
+ - Stop implicitly depending on Rack 1.4
82
92
 
83
93
  ### 0.6.2 / 2013-07-05
84
94
 
85
- * Catch errors thrown by EventMachine and emit `error` and `close` events
95
+ - Catch errors thrown by EventMachine and emit `error` and `close` events
86
96
 
87
97
  ### 0.6.1 / 2013-05-12
88
98
 
89
- * Release a gem without log and pid files in it
99
+ - Release a gem without log and pid files in it
90
100
 
91
101
  ### 0.6.0 / 2013-05-12
92
102
 
93
- * Add support for custom headers
103
+ - Add support for custom headers
94
104
 
95
105
  ### 0.5.0 / 2013-05-05
96
106
 
97
- * Extract the protocol handlers into the `websocket-driver` library
98
- * Support the `rack.hijack` API
99
- * Add support for Rainbows 4.5 and Puma
100
- * Officially support JRuby and Rubinius
107
+ - Extract the protocol handlers into the `websocket-driver` library
108
+ - Support the `rack.hijack` API
109
+ - Add support for Rainbows 4.5 and Puma
110
+ - Officially support JRuby and Rubinius
101
111
 
102
112
  ### 0.4.7 / 2013-02-14
103
113
 
104
- * Emit the `close` event if TCP is closed before CLOSE frame is acked
105
- * Treat the `Upgrade: websocket` header case-insensitively because of IE10
106
- * Do not suppress headers in the Thin and Rainbows adapters unless the status is `101`
114
+ - Emit the `close` event if TCP is closed before CLOSE frame is acked
115
+ - Treat the `Upgrade: websocket` header case-insensitively because of IE10
116
+ - Do not suppress headers in the Thin and Rainbows adapters unless the status is
117
+ `101`
107
118
 
108
119
  ### 0.4.6 / 2012-07-09
109
120
 
110
- * Add `Connection: close` to EventSource response
121
+ - Add `Connection: close` to EventSource response
111
122
 
112
123
  ### 0.4.5 / 2012-04-06
113
124
 
114
- * Add WebSocket error code `1011`.
115
- * Handle URLs with no path correctly by sending `GET /`
125
+ - Add WebSocket error code `1011`.
126
+ - Handle URLs with no path correctly by sending `GET /`
116
127
 
117
128
  ### 0.4.4 / 2012-03-16
118
129
 
119
- * Fix installation on JRuby with a platform-specific gem
130
+ - Fix installation on JRuby with a platform-specific gem
120
131
 
121
132
  ### 0.4.3 / 2012-03-12
122
133
 
123
- * Make `extconf.rb` a no-op on JRuby
134
+ - Make `extconf.rb` a no-op on JRuby
124
135
 
125
136
  ### 0.4.2 / 2012-03-09
126
137
 
127
- * Port masking-function C extension to Java for JRuby
138
+ - Port masking-function C extension to Java for JRuby
128
139
 
129
140
  ### 0.4.1 / 2012-02-26
130
141
 
131
- * Treat anything other than an `Array` as a string when calling `send()`
132
- * Fix error loading UTF-8 validation code on Ruby 1.9 with `-Ku` flag
142
+ - Treat anything other than an `Array` as a string when calling `send()`
143
+ - Fix error loading UTF-8 validation code on Ruby 1.9 with `-Ku` flag
133
144
 
134
145
  ### 0.4.0 / 2012-02-13
135
146
 
136
- * Add `ping()` method to server-side `WebSocket` and `EventSource`
137
- * Buffer `send()` calls until the draft-76 handshake is complete
147
+ - Add `ping()` method to server-side `WebSocket` and `EventSource`
148
+ - Buffer `send()` calls until the draft-76 handshake is complete
138
149
 
139
150
  ### 0.3.0 / 2012-01-13
140
151
 
141
- * Add support for `EventSource` connections
142
- * Support the Thin, Rainbows and Goliath web servers
152
+ - Add support for `EventSource` connections
153
+ - Support the Thin, Rainbows and Goliath web servers
143
154
 
144
155
  ### 0.2.0 / 2011-12-21
145
156
 
146
- * Add support for `Sec-WebSocket-Protocol` negotiation
147
- * Support `hixie-76` close frames and 75/76 ignored segments
148
- * Improve performance of HyBi parsing/framing functions
149
- * Write masking function in C
157
+ - Add support for `Sec-WebSocket-Protocol` negotiation
158
+ - Support `hixie-76` close frames and 75/76 ignored segments
159
+ - Improve performance of HyBi parsing/framing functions
160
+ - Write masking function in C
150
161
 
151
162
  ### 0.1.2 / 2011-12-05
152
163
 
153
- * Make `hixie-76` sockets work through HAProxy
164
+ - Make `hixie-76` sockets work through HAProxy
154
165
 
155
166
  ### 0.1.1 / 2011-11-30
156
167
 
157
- * Fix `add_event_listener()` interface methods
168
+ - Fix `add_event_listener()` interface methods
158
169
 
159
170
  ### 0.1.0 / 2011-11-27
160
171
 
161
- * Initial release, based on WebSocket components from Faye
172
+ - Initial release, based on WebSocket components from Faye
data/README.md CHANGED
@@ -1,9 +1,4 @@
1
- # faye-websocket
2
-
3
- * Travis CI build: [![Build
4
- status](https://secure.travis-ci.org/faye/faye-websocket-ruby.svg)](http://travis-ci.org/faye/faye-websocket-ruby)
5
- * Autobahn tests: [server](http://faye.jcoglan.com/autobahn/servers/),
6
- [client](http://faye.jcoglan.com/autobahn/clients/)
1
+ # faye-websocket [![Build status](https://secure.travis-ci.org/faye/faye-websocket-ruby.svg)](http://travis-ci.org/faye/faye-websocket-ruby)
7
2
 
8
3
  This is a general-purpose WebSocket implementation extracted from the
9
4
  [Faye](http://faye.jcoglan.com) project. It provides classes for easily building
@@ -22,11 +17,11 @@ access via proxies than WebSockets.
22
17
  The following web servers are supported. Other servers that implement the
23
18
  `rack.hijack` API should also work.
24
19
 
25
- * [Goliath](http://postrank-labs.github.com/goliath/)
26
- * [Phusion Passenger](https://www.phusionpassenger.com/) >= 4.0 with nginx >= 1.4
27
- * [Puma](http://puma.io/) >= 2.0
28
- * [Rainbows](http://rainbows.bogomips.org/)
29
- * [Thin](http://code.macournoyer.com/thin/)
20
+ - [Goliath](http://postrank-labs.github.com/goliath/)
21
+ - [Phusion Passenger](https://www.phusionpassenger.com/) >= 4.0 with nginx >= 1.4
22
+ - [Puma](http://puma.io/) >= 2.0
23
+ - [Rainbows](http://rainbows.bogomips.org/)
24
+ - [Thin](http://code.macournoyer.com/thin/)
30
25
 
31
26
 
32
27
  ## Installation
@@ -190,16 +185,16 @@ ws = Faye::WebSocket::Client.new(url, protocols, options)
190
185
  `protocols` as an array of subprotocols as described above, or `nil`. `options`
191
186
  is an optional hash containing any of these keys:
192
187
 
193
- * `:extensions` - an array of
188
+ - `:extensions` - an array of
194
189
  [websocket-extensions](https://github.com/faye/websocket-extensions-ruby)
195
190
  compatible extensions, as described above
196
- * `:headers` - a hash containing key-value pairs representing HTTP headers to be
191
+ - `:headers` - a hash containing key-value pairs representing HTTP headers to be
197
192
  sent during the handshake process
198
- * `:max_length` - the maximum allowed size of incoming message frames, in bytes.
193
+ - `:max_length` - the maximum allowed size of incoming message frames, in bytes.
199
194
  The default value is `2^26 - 1`, or 1 byte short of 64 MiB.
200
- * `:ping` - an integer that sets how often the WebSocket should send ping
195
+ - `:ping` - an integer that sets how often the WebSocket should send ping
201
196
  frames, measured in seconds
202
- * `:tls` - a hash containing key-value pairs for specifying TLS parameters.
197
+ - `:tls` - a hash containing key-value pairs for specifying TLS parameters.
203
198
  These are passed along to EventMachine and you can find
204
199
  [more details here](http://rubydoc.info/gems/eventmachine/EventMachine%2FConnection%3Astart_tls)
205
200
 
@@ -207,28 +202,28 @@ is an optional hash containing any of these keys:
207
202
 
208
203
  Both the server- and client-side `WebSocket` objects support the following API:
209
204
 
210
- * <b>`on(:open) { |event| }`</b> fires when the socket connection is
211
- established. Event has no attributes.
212
- * <b>`on(:message) { |event| }`</b> fires when the socket receives a message.
213
- Event has one attribute, <b>`data`</b>, which is either a `String` (for text
214
- frames) or an `Array` of byte-sized integers (for binary frames).
215
- * <b>`on(:error) { |event| }`</b> fires when there is a protocol error due to
216
- bad data sent by the other peer. This event is purely informational, you do
217
- not need to implement error recovery.
218
- * <b>`on(:close) { |event| }`</b> fires when either the client or the server
219
- closes the connection. Event has two optional attributes, <b>`code`</b> and
220
- <b>`reason`</b>, that expose the status code and message sent by the peer that
205
+ - **`on(:open) { |event| }`** fires when the socket connection is established.
206
+ Event has no attributes.
207
+ - **`on(:message) { |event| }`** fires when the socket receives a message. Event
208
+ has one attribute, **`data`**, which is either a `String` (for text frames) or
209
+ an `Array` of byte-sized integers (for binary frames).
210
+ - **`on(:error) { |event| }`** fires when there is a protocol error due to bad
211
+ data sent by the other peer. This event is purely informational, you do not
212
+ need to implement error recovery.
213
+ - **`on(:close) { |event| }`** fires when either the client or the server closes
214
+ the connection. Event has two optional attributes, **`code`** and
215
+ **`reason`**, that expose the status code and message sent by the peer that
221
216
  closed the connection.
222
- * <b>`send(message)`</b> accepts either a `String` or an `Array` of byte-sized
217
+ - **`send(message)`** accepts either a `String` or an `Array` of byte-sized
223
218
  integers and sends a text or binary message over the connection to the other
224
219
  peer; binary data must be encoded as an `Array`.
225
- * <b>`ping(message, &callback)`</b> sends a ping frame with an optional message
226
- and fires the callback when a matching pong is received.
227
- * <b>`close(code, reason)`</b> closes the connection, sending the given status
228
- code and reason text, both of which are optional.
229
- * <b>`version`</b> is a string containing the version of the `WebSocket`
230
- protocol the connection is using.
231
- * <b>`protocol`</b> is a string (which may be empty) identifying the subprotocol
220
+ - **`ping(message, &callback)`** sends a ping frame with an optional message and
221
+ fires the callback when a matching pong is received.
222
+ - **`close(code, reason)`** closes the connection, sending the given status code
223
+ and reason text, both of which are optional.
224
+ - **`version`** is a string containing the version of the `WebSocket` protocol
225
+ the connection is using.
226
+ - **`protocol`** is a string (which may be empty) identifying the subprotocol
232
227
  the socket is using.
233
228
 
234
229
 
@@ -276,22 +271,22 @@ es.send('Breaking News!', :event => 'notification', :id => '99')
276
271
 
277
272
  The `EventSource` object exposes the following properties:
278
273
 
279
- * <b>`url`</b> is a string containing the URL the client used to create the
274
+ - **`url`** is a string containing the URL the client used to create the
280
275
  EventSource.
281
- * <b>`last_event_id`</b> is a string containing the last event ID received by
282
- the client. You can use this when the client reconnects after a dropped
283
- connection to determine which messages need resending.
276
+ - **`last_event_id`** is a string containing the last event ID received by the
277
+ client. You can use this when the client reconnects after a dropped connection
278
+ to determine which messages need resending.
284
279
 
285
280
  When you initialize an EventSource with `Faye::EventSource.new`, you can pass
286
281
  configuration options after the `env` parameter. Available options are:
287
282
 
288
- * <b>`:headers`</b> is a hash containing custom headers to be set on the
283
+ - **`:headers`** is a hash containing custom headers to be set on the
289
284
  EventSource response.
290
- * <b>`:retry`</b> is a number that tells the client how long (in seconds) it
291
- should wait after a dropped connection before attempting to reconnect.
292
- * <b>`:ping`</b> is a number that tells the server how often (in seconds) to
293
- send 'ping' packets to the client to keep the connection open, to defeat
294
- timeouts set by proxies. The client will ignore these messages.
285
+ - **`:retry`** is a number that tells the client how long (in seconds) it should
286
+ wait after a dropped connection before attempting to reconnect.
287
+ - **`:ping`** is a number that tells the server how often (in seconds) to send
288
+ 'ping' packets to the client to keep the connection open, to defeat timeouts
289
+ set by proxies. The client will ignore these messages.
295
290
 
296
291
  For example, this creates a connection that allows access from any origin, pings
297
292
  every 15 seconds and is retryable every 10 seconds if the connection is broken:
@@ -487,27 +482,3 @@ class EchoServer < Goliath::API
487
482
  end
488
483
  end
489
484
  ```
490
-
491
-
492
- ## License
493
-
494
- (The MIT License)
495
-
496
- Copyright (c) 2010-2017 James Coglan
497
-
498
- Permission is hereby granted, free of charge, to any person obtaining a copy of
499
- this software and associated documentation files (the 'Software'), to deal in
500
- the Software without restriction, including without limitation the rights to
501
- use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
502
- the Software, and to permit persons to whom the Software is furnished to do so,
503
- subject to the following conditions:
504
-
505
- The above copyright notice and this permission notice shall be included in all
506
- copies or substantial portions of the Software.
507
-
508
- THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
509
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
510
- FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
511
- COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
512
- IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
513
- CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,4 +1,3 @@
1
- require 'rubygems'
2
1
  require 'bundler/setup'
3
2
  require 'cgi'
4
3
  require 'faye/websocket'
@@ -6,9 +5,12 @@ require 'permessage_deflate'
6
5
  require 'progressbar'
7
6
 
8
7
  EM.run {
9
- host = 'ws://localhost:9001'
10
- ruby = RUBY_PLATFORM =~ /java/ ? 'jruby' : 'cruby'
11
- agent = CGI.escape("#{ruby}-#{RUBY_VERSION}")
8
+ ruby = RUBY_PLATFORM =~ /java/ ? 'jruby' : 'mri-ruby'
9
+ version = defined?(RUBY_ENGINE_VERSION) ? RUBY_ENGINE_VERSION : RUBY_VERSION
10
+ version += " (#{RUBY_VERSION})" if ruby == 'jruby'
11
+
12
+ host = 'ws://0.0.0.0:9001'
13
+ agent = CGI.escape("#{ruby}-#{version}")
12
14
  cases = 0
13
15
  options = {:extensions => [PermessageDeflate]}
14
16
 
@@ -1,4 +1,3 @@
1
- require 'rubygems'
2
1
  require 'bundler/setup'
3
2
  require 'faye/websocket'
4
3
  require 'eventmachine'
@@ -3,7 +3,6 @@
3
3
  # thin start -R examples/config.ru -p 7000
4
4
  # rainbows -c examples/rainbows.conf -E production examples/config.ru -p 7000
5
5
 
6
- require 'rubygems'
7
6
  require 'bundler/setup'
8
7
  require File.expand_path('../app', __FILE__)
9
8
 
@@ -1,4 +1,3 @@
1
- require 'rubygems'
2
1
  require 'bundler/setup'
3
2
  require 'eventmachine'
4
3
  require 'websocket/driver'
@@ -1,4 +1,3 @@
1
- require 'rubygems'
2
1
  require 'bundler/setup'
3
2
  require 'rack/content_length'
4
3
  require 'rack/chunked'
@@ -40,7 +39,7 @@ when 'rainbows'
40
39
 
41
40
  when 'thin'
42
41
  thin = Rack::Handler.get('thin')
43
- thin.run(App, :Port => port) do |server|
42
+ thin.run(App, :Host => '0.0.0.0', :Port => port) do |server|
44
43
  if secure
45
44
  server.ssl_options = {
46
45
  :private_key_file => spec + '/server.key',
@@ -43,7 +43,7 @@ module Faye
43
43
 
44
44
  @driver.on(:open) { |e| open }
45
45
  @driver.on(:message) { |e| receive_message(e.data) }
46
- @driver.on(:close) { |e| begin_close(e.reason, e.code) }
46
+ @driver.on(:close) { |e| begin_close(e.reason, e.code, :wait_for_write => true) }
47
47
 
48
48
  @driver.on(:error) do |error|
49
49
  emit_error(error.message)
@@ -87,9 +87,9 @@ module Faye
87
87
  end
88
88
 
89
89
  @ready_state = CLOSING unless @ready_state == CLOSED
90
- @driver.close(reason, code)
91
-
92
90
  @close_timer = EventMachine.add_timer(CLOSE_TIMEOUT) { begin_close('', 1006) }
91
+
92
+ @driver.close(reason, code)
93
93
  end
94
94
 
95
95
  def protocol
@@ -121,13 +121,17 @@ module Faye
121
121
  dispatch_event(event)
122
122
  end
123
123
 
124
- def begin_close(reason, code)
124
+ def begin_close(reason, code, options = {})
125
125
  return if @ready_state == CLOSED
126
126
  @ready_state = CLOSING
127
127
  @close_params = [reason, code]
128
128
 
129
129
  if @stream
130
- @stream.close_connection_after_writing
130
+ if options[:wait_for_write]
131
+ @stream.close_connection_after_writing
132
+ else
133
+ @stream.close_connection
134
+ end
131
135
  else
132
136
  finalize_close
133
137
  end
@@ -23,29 +23,7 @@ module Faye
23
23
  @origin_tls = options.fetch(:tls, {})
24
24
  @socket_tls = proxy[:origin] ? proxy.fetch(:tls, {}) : @origin_tls
25
25
 
26
- if proxy[:origin]
27
- @proxy = @driver.proxy(proxy[:origin])
28
- if headers = proxy[:headers]
29
- headers.each { |name, value| @proxy.set_header(name, value) }
30
- end
31
-
32
- @proxy.on(:connect) do
33
- uri = URI.parse(@url)
34
- secure = SECURE_PROTOCOLS.include?(uri.scheme)
35
- @proxy = nil
36
-
37
- if secure
38
- origin_tls = {:sni_hostname => uri.host}.merge(@origin_tls)
39
- @stream.start_tls(origin_tls)
40
- end
41
-
42
- @driver.start
43
- end
44
-
45
- @proxy.on(:error) do |error|
46
- @driver.emit(:error, error)
47
- end
48
- end
26
+ configure_proxy(proxy)
49
27
 
50
28
  EventMachine.connect(endpoint.host, port, Connection) do |conn|
51
29
  conn.parent = self
@@ -57,6 +35,30 @@ module Faye
57
35
 
58
36
  private
59
37
 
38
+ def configure_proxy(proxy)
39
+ return unless proxy[:origin]
40
+
41
+ @proxy = @driver.proxy(proxy[:origin])
42
+ @proxy.on(:error) { |error| @driver.emit(:error, error) }
43
+
44
+ if headers = proxy[:headers]
45
+ headers.each { |name, value| @proxy.set_header(name, value) }
46
+ end
47
+
48
+ @proxy.on(:connect) do
49
+ uri = URI.parse(@url)
50
+ secure = SECURE_PROTOCOLS.include?(uri.scheme)
51
+ @proxy = nil
52
+
53
+ if secure
54
+ origin_tls = {:sni_hostname => uri.host}.merge(@origin_tls)
55
+ @stream.start_tls(origin_tls)
56
+ end
57
+
58
+ @driver.start
59
+ end
60
+ end
61
+
60
62
  def on_connect(stream)
61
63
  @stream = stream
62
64
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: faye-websocket
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.7
4
+ version: 0.10.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Coglan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-22 00:00:00.000000000 Z
11
+ date: 2019-06-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: eventmachine
@@ -66,20 +66,6 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
- - !ruby/object:Gem::Dependency
70
- name: public_suffix
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - "<"
74
- - !ruby/object:Gem::Version
75
- version: 1.5.0
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - "<"
81
- - !ruby/object:Gem::Version
82
- version: 1.5.0
83
69
  - !ruby/object:Gem::Dependency
84
70
  name: puma
85
71
  requirement: !ruby/object:Gem::Requirement
@@ -168,14 +154,14 @@ dependencies:
168
154
  name: goliath
169
155
  requirement: !ruby/object:Gem::Requirement
170
156
  requirements:
171
- - - ">="
157
+ - - ">"
172
158
  - !ruby/object:Gem::Version
173
159
  version: '0'
174
160
  type: :development
175
161
  prerelease: false
176
162
  version_requirements: !ruby/object:Gem::Requirement
177
163
  requirements:
178
- - - ">="
164
+ - - ">"
179
165
  - !ruby/object:Gem::Version
180
166
  version: '0'
181
167
  - !ruby/object:Gem::Dependency
@@ -225,7 +211,7 @@ files:
225
211
  - lib/faye/websocket/client.rb
226
212
  homepage: https://github.com/faye/faye-websocket-ruby
227
213
  licenses:
228
- - MIT
214
+ - Apache-2.0
229
215
  metadata: {}
230
216
  post_install_message:
231
217
  rdoc_options:
@@ -246,8 +232,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
246
232
  - !ruby/object:Gem::Version
247
233
  version: '0'
248
234
  requirements: []
249
- rubyforge_project:
250
- rubygems_version: 2.6.8
235
+ rubygems_version: 3.0.3
251
236
  signing_key:
252
237
  specification_version: 4
253
238
  summary: Standards-compliant WebSocket server and client