websocket-driver 0.7.5 → 0.7.6

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: 046c514660d2c0dab2cf42bce8314a17e713909377a5da470beaeadf666ff28e
4
- data.tar.gz: 9830c412394044d102dd6f313346721076ef0f97284d6182aeb06862e1f427b2
3
+ metadata.gz: 48624348056a8a90b22cf6844120166be3ec700a80ec4ab23c1d6c1f5e43aa1a
4
+ data.tar.gz: 0f157eaba15f2cd8c544042700159a692b0bf74f71a03c40b3da04a705409236
5
5
  SHA512:
6
- metadata.gz: cea4027f342f51a688c8004a92ca29b68af9a9395b5e7f8d2462b8742067862718d23f4be9ca6162f761774490e4cdf33111bb746f9221d5acace6546a749b35
7
- data.tar.gz: d124aa6acf1cbfa498b44d02d6aa659c99e97e177441e8cbd43958db38c6cf03d703d26ae73998a09719c0612f538554049d58b58aa8cc8ab5f0bb458e27c988
6
+ metadata.gz: f27c8eafe669ee83b263f56d1b0aeb49bcfba6c5bcc1b027b3bf3a04f71c58e7d9bc6fa99a24f8f4724f6f3d5961a7c90c2fdea978b6f9f1324d5a3f1012d056
7
+ data.tar.gz: 833502731fc73a3b05664d29343199e4c07e5b77825b5a3b2b851d6742506d7c33207a5da0369f692cc073c0e192583db083ba127abaa85eb9b130b4ac1aeb7f
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ### 0.7.6 / 2023-07-25
2
+
3
+ - Fix handling of default ports in `Host` headers on Ruby 3.1+
4
+
1
5
  ### 0.7.5 / 2021-06-12
2
6
 
3
7
  - Do not change the encoding of strings passed to `Driver#text`
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
 
@@ -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)
@@ -209,6 +210,14 @@ module WebSocket
209
210
  data.force_encoding(encoding)
210
211
  end
211
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}"
217
+ end
218
+ host
219
+ end
220
+
212
221
  def self.validate_options(options, valid_keys)
213
222
  options.keys.each do |key|
214
223
  unless valid_keys.include?(key)
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.5
4
+ version: 0.7.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Coglan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-06-12 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
  name: websocket-extensions
@@ -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.1.6
138
+ rubygems_version: 3.4.10
139
139
  signing_key:
140
140
  specification_version: 4
141
141
  summary: WebSocket protocol handler with pluggable I/O