websocket-driver 0.7.4-java → 0.7.6-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: cd9397ef6b3c46b55d4f5809f8b359f261b983f5a29442d6cbb9791fb40761d8
4
- data.tar.gz: 871848fa7118981c4543d4533f4a0a845ff848b5da639e42f16f7f5f6762231a
3
+ metadata.gz: 9234ae31d300336b8d2faee422f5fe665b1874066b18429c32f3e473ad178903
4
+ data.tar.gz: d66d556cd9fdcdf3d2392deb9e6c0f41c672c9b10436e9024e0db17a5a083e77
5
5
  SHA512:
6
- metadata.gz: 1d9b3b03d2ada8d5757d7a2ea189097a2b31b4ffbd980317d88176826aa77db2be291a89d8280533d3e3f79c46997d157c540a2d2ef77f3a80c2d00b5bd7965c
7
- data.tar.gz: f87b7664488e57fc8e976809b6554dd05cac016961fef21efa7331917bb247be14f24dbe4642ae909e295d1c61dedb5a5e42d44d298b10921acbd3bf4aa69293
6
+ metadata.gz: 9f6b174444c6ee089a9abb11d30480b098d7071914804f76349ceb31e941c8652843878afd794b7e419e20a83c3ab7c8f4af01e44c84865c852cec449287fc91
7
+ data.tar.gz: c1665d4a0c60ad42a20324918abeed7de14301b4ca6a72ba022211a128865a77e25831fc67714f023fac864812dc18f4fc298656d6e54e8ea8e59ba624531757
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ ### 0.7.6 / 2023-07-25
2
+
3
+ - Fix handling of default ports in `Host` headers on Ruby 3.1+
4
+
5
+ ### 0.7.5 / 2021-06-12
6
+
7
+ - Do not change the encoding of strings passed to `Driver#text`
8
+
1
9
  ### 0.7.4 / 2021-05-24
2
10
 
3
11
  - Optimise conversions between strings and byte arrays and related encoding
data/LICENSE.md CHANGED
@@ -1,4 +1,4 @@
1
- Copyright 2010-2021 James Coglan
1
+ Copyright 2010-2023 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
@@ -23,11 +23,10 @@ module WebSocket
23
23
  raise URIError, "#{ socket.url } is not a valid WebSocket URL"
24
24
  end
25
25
 
26
- host = uri.host + (uri.port ? ":#{ uri.port }" : '')
27
26
  path = (uri.path == '') ? '/' : uri.path
28
27
  @pathname = path + (uri.query ? '?' + uri.query : '')
29
28
 
30
- @headers['Host'] = host
29
+ @headers['Host'] = Driver.host_header(uri)
31
30
  @headers['Upgrade'] = 'websocket'
32
31
  @headers['Connection'] = 'Upgrade'
33
32
  @headers['Sec-WebSocket-Key'] = @key
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: false
2
+
1
3
  module WebSocket
2
4
  class Driver
3
5
 
@@ -164,7 +166,7 @@ module WebSocket
164
166
  message.rsv1 = message.rsv2 = message.rsv3 = false
165
167
  message.opcode = OPCODES[type || (String === buffer ? :text : :binary)]
166
168
 
167
- payload = Driver.encode(buffer, Encoding::BINARY)
169
+ payload = Driver.encode(buffer)
168
170
  payload = [code, payload].pack('S>a*') if code
169
171
  message.data = payload
170
172
 
@@ -4,8 +4,6 @@ module WebSocket
4
4
  class Proxy
5
5
  include EventEmitter
6
6
 
7
- PORTS = { 'ws' => 80, 'wss' => 443 }
8
-
9
7
  attr_reader :status, :headers
10
8
 
11
9
  def initialize(client, origin, options)
@@ -20,7 +18,7 @@ module WebSocket
20
18
  @state = 0
21
19
 
22
20
  @headers = Headers.new
23
- @headers['Host'] = @origin.host + (@origin.port ? ":#{ @origin.port }" : '')
21
+ @headers['Host'] = Driver.host_header(@origin)
24
22
  @headers['Connection'] = 'keep-alive'
25
23
  @headers['Proxy-Connection'] = 'keep-alive'
26
24
 
@@ -42,6 +42,7 @@ module WebSocket
42
42
  end
43
43
 
44
44
  MAX_LENGTH = 0x3ffffff
45
+ PORTS = { 'ws' => 80, 'wss' => 443 }
45
46
  STATES = [:connecting, :open, :closing, :closed]
46
47
 
47
48
  ConnectEvent = Struct.new(nil)
@@ -115,7 +116,7 @@ module WebSocket
115
116
  end
116
117
 
117
118
  def text(message)
118
- message = message.encode(Encoding::UTF_8) unless message.encoding == Encoding::UTF_8
119
+ message = Driver.encode(message, Encoding::UTF_8)
119
120
  frame(message, :text)
120
121
  end
121
122
 
@@ -194,19 +195,27 @@ module WebSocket
194
195
  end
195
196
  end
196
197
 
197
- def self.encode(string, encoding = nil)
198
- case string
199
- when Array then
200
- string = string.pack('C*')
201
- encoding ||= Encoding::BINARY
202
- when String then
203
- encoding ||= Encoding::UTF_8
198
+ def self.encode(data, encoding = nil)
199
+ if Array === data
200
+ encoding ||= Encoding::BINARY
201
+ return data.pack('C*').force_encoding(encoding)
204
202
  end
205
- unless string.encoding == encoding
206
- string = string.dup if string.frozen?
207
- string.force_encoding(encoding)
203
+
204
+ encoding ||= Encoding::UTF_8
205
+
206
+ return data if data.encoding == encoding
207
+ return data.encode(encoding) unless data.encoding == Encoding::BINARY
208
+
209
+ data = data.dup if data.frozen?
210
+ data.force_encoding(encoding)
211
+ end
212
+
213
+ def self.host_header(uri)
214
+ host = uri.host
215
+ if uri.port and uri.port != PORTS[uri.scheme]
216
+ host += ":#{uri.port}"
208
217
  end
209
- string
218
+ host
210
219
  end
211
220
 
212
221
  def self.validate_options(options, valid_keys)
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.4
4
+ version: 0.7.6
5
5
  platform: java
6
6
  authors:
7
7
  - James Coglan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-05-24 00:00:00.000000000 Z
11
+ date: 2023-07-25 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
- type: :runtime
21
20
  prerelease: false
21
+ type: :runtime
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
- type: :development
35
34
  prerelease: false
35
+ type: :development
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
- type: :development
49
48
  prerelease: false
49
+ type: :development
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
- type: :development
63
62
  prerelease: false
63
+ type: :development
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
- type: :development
77
76
  prerelease: false
77
+ type: :development
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - ">="
@@ -135,7 +135,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
135
135
  - !ruby/object:Gem::Version
136
136
  version: '0'
137
137
  requirements: []
138
- rubygems_version: 3.0.6
138
+ rubygems_version: 3.3.25
139
139
  signing_key:
140
140
  specification_version: 4
141
141
  summary: WebSocket protocol handler with pluggable I/O