websocket-driver 0.7.1-java → 0.7.2-java

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bed08ef47579269780c5c93cae6f3c181297a000c20725b2bb17ccfe6d7c9a92
4
- data.tar.gz: 54b3292f8e301ab2d8489e144d457dd490e607741607927d23e318c1b53286c7
3
+ metadata.gz: e1f35596f08035e52c35d9d882301309148070aadfae0c5018bf97a4885101f2
4
+ data.tar.gz: a532f2969c360c47f11c4eee7260a805f3b2858d5b80f30fa41240c40d357fff
5
5
  SHA512:
6
- metadata.gz: 8b01940d4d8d6d667da9daa0d54e9250cdf4f9d1a78273ab6a58a71b46d8880b19628069d0e54ad9d9daff1590268f8cb7c3b4e55873bce955ed7278d805be61
7
- data.tar.gz: 886d18cb114222c6a89a6782564624fb1780a3e32b243eb2b560224d1635522f00a6b7515e45b0bb52425b281a3e29ec94379d1be75e198d2c9d03cf9e4e41ce
6
+ metadata.gz: ac3ffd73ef983bc0cec1bb1de9c9672a3682232775ea8021559ee952bab21a88bf712f6707059668d1ea039a888a493950aa01992b9240c64553d2ad0c430366
7
+ data.tar.gz: '083628e6cd562465acc010242dd5442688ec54c2e00fcecced8c43225f66e37cc7949aecd9004ed7728d65981cbfdab11a496c062de5516fcd14f576941f0841'
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ### 0.7.2 / 2020-05-22
2
+
3
+ - Emit `ping` and `pong` events from the `Server` driver
4
+ - Handle draft-76 handshakes correctly if the request's body is a frozen string
5
+
1
6
  ### 0.7.1 / 2019-06-10
2
7
 
3
8
  - Catch any exceptions produced while generating a handshake response and send a
@@ -5,6 +10,7 @@
5
10
  - Pick the RFC-6455 protocol version if the request contains any of the headers
6
11
  used by that version
7
12
  - Handle errors encountered while handling malformed draft-76 requests
13
+ - Change license from MIT to Apache 2.0
8
14
 
9
15
  ### 0.7.0 / 2017-09-11
10
16
 
data/LICENSE.md CHANGED
@@ -1,4 +1,4 @@
1
- Copyright 2010-2019 James Coglan
1
+ Copyright 2010-2020 James Coglan
2
2
 
3
3
  Licensed under the Apache License, Version 2.0 (the "License"); you may not use
4
4
  this file except in compliance with the License. You may obtain a copy of the
data/README.md CHANGED
@@ -274,33 +274,33 @@ Note that most of these methods are commands: if they produce data that should
274
274
  be sent over the socket, they will give this to you by calling
275
275
  `socket.write(string)`.
276
276
 
277
- #### `driver.on :open, -> (event) { }`
277
+ #### `driver.on :open, -> (event) {}`
278
278
 
279
279
  Adds a callback block to execute when the socket becomes open.
280
280
 
281
- #### `driver.on :message, -> (event) { }`
281
+ #### `driver.on :message, -> (event) {}`
282
282
 
283
283
  Adds a callback block to execute when a message is received. `event` will have a
284
284
  `data` attribute containing either a string in the case of a text message or an
285
285
  array of integers in the case of a binary message.
286
286
 
287
- #### `driver.on :error, -> (event) { }`
287
+ #### `driver.on :error, -> (event) {}`
288
288
 
289
289
  Adds a callback to execute when a protocol error occurs due to the other peer
290
290
  sending an invalid byte sequence. `event` will have a `message` attribute
291
291
  describing the error.
292
292
 
293
- #### `driver.on :close, -> (event) { }`
293
+ #### `driver.on :close, -> (event) {}`
294
294
 
295
295
  Adds a callback block to execute when the socket becomes closed. The `event`
296
296
  object has `code` and `reason` attributes.
297
297
 
298
- #### `driver.on :ping, -> (event) { }`
298
+ #### `driver.on :ping, -> (event) {}`
299
299
 
300
300
  Adds a callback block to execute when a ping is received. You do not need to
301
301
  handle this by sending a pong frame yourself; the driver handles this for you.
302
302
 
303
- #### `driver.on :pong, -> (event) { }`
303
+ #### `driver.on :pong, -> (event) {}`
304
304
 
305
305
  Adds a callback block to execute when a pong is received. If this was in
306
306
  response to a ping you sent, you can also handle this event via the
@@ -215,7 +215,7 @@ module WebSocket
215
215
  def self.validate_options(options, valid_keys)
216
216
  options.keys.each do |key|
217
217
  unless valid_keys.include?(key)
218
- raise ConfigurationError, "Unrecognized option: #{key.inspect}"
218
+ raise ConfigurationError, "Unrecognized option: #{ key.inspect }"
219
219
  end
220
220
  end
221
221
  end
@@ -20,10 +20,10 @@ module WebSocket
20
20
 
21
21
  uri = URI.parse(@socket.url)
22
22
  unless VALID_SCHEMES.include?(uri.scheme)
23
- raise URIError, "#{socket.url} is not a valid WebSocket URL"
23
+ raise URIError, "#{ socket.url } is not a valid WebSocket URL"
24
24
  end
25
25
 
26
- host = uri.host + (uri.port ? ":#{uri.port}" : '')
26
+ host = uri.host + (uri.port ? ":#{ uri.port }" : '')
27
27
  path = (uri.path == '') ? '/' : uri.path
28
28
  @pathname = path + (uri.query ? '?' + uri.query : '')
29
29
 
@@ -44,7 +44,7 @@ module WebSocket
44
44
  end
45
45
 
46
46
  def version
47
- "hybi-#{VERSION}"
47
+ "hybi-#{ VERSION }"
48
48
  end
49
49
 
50
50
  def proxy(origin, options = {})
@@ -73,19 +73,19 @@ module WebSocket
73
73
  parse(@http.body)
74
74
  end
75
75
 
76
- private
76
+ private
77
77
 
78
78
  def handshake_request
79
79
  extensions = @extensions.generate_offer
80
80
  @headers['Sec-WebSocket-Extensions'] = extensions if extensions
81
81
 
82
- start = "GET #{@pathname} HTTP/1.1"
82
+ start = "GET #{ @pathname } HTTP/1.1"
83
83
  headers = [start, @headers.to_s, '']
84
84
  headers.join("\r\n")
85
85
  end
86
86
 
87
87
  def fail_handshake(message)
88
- message = "Error during WebSocket handshake: #{message}"
88
+ message = "Error during WebSocket handshake: #{ message }"
89
89
  @ready_state = 3
90
90
  emit(:error, ProtocolError.new(message))
91
91
  emit(:close, CloseEvent.new(ERRORS[:protocol_error], message))
@@ -96,7 +96,7 @@ module WebSocket
96
96
  @headers = Headers.new(@http.headers)
97
97
 
98
98
  unless @http.code == 101
99
- return fail_handshake("Unexpected response code: #{@http.code}")
99
+ return fail_handshake("Unexpected response code: #{ @http.code }")
100
100
  end
101
101
 
102
102
  upgrade = @http['Upgrade'] || ''
@@ -6,9 +6,10 @@ module WebSocket
6
6
 
7
7
  def initialize(socket, options = {})
8
8
  super
9
- input = @socket.env['rack.input']
9
+ input = (@socket.env['rack.input'] || StringIO.new('')).read
10
+ input = input.dup if input.frozen?
10
11
  @stage = -1
11
- @body = (input ? input.read : String.new('')).force_encoding(BINARY)
12
+ @body = input.force_encoding(BINARY)
12
13
 
13
14
  @headers.clear
14
15
  @headers['Upgrade'] = 'WebSocket'
@@ -25,7 +25,7 @@ module WebSocket
25
25
  return if value.nil?
26
26
  key = HTTP.normalize_header(name)
27
27
  return unless @sent.add?(key) or ALLOWED_DUPLICATES.include?(key)
28
- @lines << "#{name.strip}: #{value.to_s.strip}\r\n"
28
+ @lines << "#{ name.strip }: #{ value.to_s.strip }\r\n"
29
29
  end
30
30
 
31
31
  def inspect
@@ -52,7 +52,7 @@ module WebSocket
52
52
  MIN_RESERVED_ERROR = 3000
53
53
  MAX_RESERVED_ERROR = 4999
54
54
 
55
- PACK_FORMATS = {2 => 'n', 8 => 'Q>'}
55
+ PACK_FORMATS = { 2 => 'n', 8 => 'Q>' }
56
56
 
57
57
  def initialize(socket, options = {})
58
58
  super
@@ -78,7 +78,7 @@ module WebSocket
78
78
  end
79
79
 
80
80
  def version
81
- "hybi-#{VERSION}"
81
+ "hybi-#{ VERSION }"
82
82
  end
83
83
 
84
84
  def add_extension(extension)
@@ -228,7 +228,7 @@ module WebSocket
228
228
  version = @socket.env['HTTP_SEC_WEBSOCKET_VERSION']
229
229
 
230
230
  unless version == VERSION
231
- raise ProtocolError.new("Unsupported WebSocket version: #{VERSION}")
231
+ raise ProtocolError.new("Unsupported WebSocket version: #{ VERSION }")
232
232
  end
233
233
 
234
234
  unless sec_key
@@ -281,17 +281,17 @@ module WebSocket
281
281
 
282
282
  unless @extensions.valid_frame_rsv?(@frame)
283
283
  return fail(:protocol_error,
284
- "One or more reserved bits are on: reserved1 = #{@frame.rsv1 ? 1 : 0}" +
285
- ", reserved2 = #{@frame.rsv2 ? 1 : 0 }" +
286
- ", reserved3 = #{@frame.rsv3 ? 1 : 0 }")
284
+ "One or more reserved bits are on: reserved1 = #{ @frame.rsv1 ? 1 : 0 }" +
285
+ ", reserved2 = #{ @frame.rsv2 ? 1 : 0 }" +
286
+ ", reserved3 = #{ @frame.rsv3 ? 1 : 0 }")
287
287
  end
288
288
 
289
289
  unless OPCODES.values.include?(@frame.opcode)
290
- return fail(:protocol_error, "Unrecognized frame opcode: #{@frame.opcode}")
290
+ return fail(:protocol_error, "Unrecognized frame opcode: #{ @frame.opcode }")
291
291
  end
292
292
 
293
293
  unless MESSAGE_OPCODES.include?(@frame.opcode) or @frame.final
294
- return fail(:protocol_error, "Received fragmented control frame: opcode = #{@frame.opcode}")
294
+ return fail(:protocol_error, "Received fragmented control frame: opcode = #{ @frame.opcode }")
295
295
  end
296
296
 
297
297
  if @message and OPENING_OPCODES.include?(@frame.opcode)
@@ -321,7 +321,7 @@ module WebSocket
321
321
  @stage = @frame.masked ? 3 : 4
322
322
 
323
323
  unless MESSAGE_OPCODES.include?(@frame.opcode) or @frame.length <= 125
324
- return fail(:protocol_error, "Received control frame having too long payload: #{@frame.length}")
324
+ return fail(:protocol_error, "Received control frame having too long payload: #{ @frame.length }")
325
325
  end
326
326
 
327
327
  return unless check_frame_length
@@ -4,7 +4,7 @@ module WebSocket
4
4
  class Proxy
5
5
  include EventEmitter
6
6
 
7
- PORTS = {'ws' => 80, 'wss' => 443}
7
+ PORTS = { 'ws' => 80, 'wss' => 443 }
8
8
 
9
9
  attr_reader :status, :headers
10
10
 
@@ -20,7 +20,7 @@ module WebSocket
20
20
  @state = 0
21
21
 
22
22
  @headers = Headers.new
23
- @headers['Host'] = @origin.host + (@origin.port ? ":#{@origin.port}" : '')
23
+ @headers['Host'] = @origin.host + (@origin.port ? ":#{ @origin.port }" : '')
24
24
  @headers['Connection'] = 'keep-alive'
25
25
  @headers['Proxy-Connection'] = 'keep-alive'
26
26
 
@@ -41,7 +41,7 @@ module WebSocket
41
41
  @state = 1
42
42
 
43
43
  port = @origin.port || PORTS[@origin.scheme]
44
- start = "CONNECT #{@origin.host}:#{port} HTTP/1.1"
44
+ start = "CONNECT #{ @origin.host }:#{ port } HTTP/1.1"
45
45
  headers = [start, @headers.to_s, '']
46
46
 
47
47
  @socket.write(headers.join("\r\n"))
@@ -58,7 +58,7 @@ module WebSocket
58
58
  if @status == 200
59
59
  emit(:connect, ConnectEvent.new)
60
60
  else
61
- message = "Can't establish a connection to the server at #{@socket.url}"
61
+ message = "Can't establish a connection to the server at #{ @socket.url }"
62
62
  emit(:error, ProtocolError.new(message))
63
63
  end
64
64
  end
@@ -2,7 +2,7 @@ module WebSocket
2
2
  class Driver
3
3
 
4
4
  class Server < Driver
5
- EVENTS = %w[open message error close]
5
+ EVENTS = %w[open message error close ping pong]
6
6
 
7
7
  def initialize(socket, options = {})
8
8
  super
@@ -17,9 +17,9 @@ module WebSocket
17
17
  def url
18
18
  return nil unless e = env
19
19
 
20
- url = "ws://#{e['HTTP_HOST']}"
20
+ url = "ws://#{ e['HTTP_HOST'] }"
21
21
  url << e['PATH_INFO']
22
- url << "?#{e['QUERY_STRING']}" unless e['QUERY_STRING'] == ''
22
+ url << "?#{ e['QUERY_STRING'] }" unless e['QUERY_STRING'] == ''
23
23
  url
24
24
  end
25
25
 
@@ -30,11 +30,11 @@ module WebSocket
30
30
  super
31
31
  @headers.each do |name, value|
32
32
  rack_name = name.upcase.gsub(/-/, '_')
33
- rack_name = "HTTP_#{rack_name}" unless RESERVED_HEADERS.include?(name)
33
+ rack_name = "HTTP_#{ rack_name }" unless RESERVED_HEADERS.include?(name)
34
34
  @env[rack_name] = value
35
35
  end
36
36
  if host = @env['HTTP_HOST']
37
- uri = URI.parse("http://#{host}")
37
+ uri = URI.parse("http://#{ host }")
38
38
  @env['SERVER_NAME'] = uri.host
39
39
  @env['SERVER_PORT'] = uri.port.to_s
40
40
  end
Binary file
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: websocket-driver
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.1
4
+ version: 0.7.2
5
5
  platform: java
6
6
  authors:
7
7
  - James Coglan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-06-10 00:00:00.000000000 Z
11
+ date: 2020-05-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -17,8 +17,8 @@ dependencies:
17
17
  - !ruby/object:Gem::Version
18
18
  version: 0.1.0
19
19
  name: websocket-extensions
20
- prerelease: false
21
20
  type: :runtime
21
+ prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
@@ -31,8 +31,8 @@ dependencies:
31
31
  - !ruby/object:Gem::Version
32
32
  version: '0'
33
33
  name: eventmachine
34
- prerelease: false
35
34
  type: :development
35
+ prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ">="
@@ -45,8 +45,8 @@ dependencies:
45
45
  - !ruby/object:Gem::Version
46
46
  version: '0'
47
47
  name: permessage_deflate
48
- prerelease: false
49
48
  type: :development
49
+ prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - ">="
@@ -59,8 +59,8 @@ dependencies:
59
59
  - !ruby/object:Gem::Version
60
60
  version: '0'
61
61
  name: rake-compiler
62
- prerelease: false
63
62
  type: :development
63
+ prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - ">="
@@ -73,8 +73,8 @@ dependencies:
73
73
  - !ruby/object:Gem::Version
74
74
  version: '0'
75
75
  name: rspec
76
- prerelease: false
77
76
  type: :development
77
+ prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - ">="
@@ -135,8 +135,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
135
135
  - !ruby/object:Gem::Version
136
136
  version: '0'
137
137
  requirements: []
138
- rubyforge_project:
139
- rubygems_version: 2.7.6
138
+ rubygems_version: 3.0.6
140
139
  signing_key:
141
140
  specification_version: 4
142
141
  summary: WebSocket protocol handler with pluggable I/O