websocket 1.2.1 → 1.2.2
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 +4 -4
 - data/.travis.yml +3 -3
 - data/CHANGELOG.md +4 -0
 - data/README.md +2 -2
 - data/lib/websocket/handshake/client.rb +3 -2
 - data/lib/websocket/handshake/handler.rb +1 -0
 - data/lib/websocket/handshake/handler/client11.rb +22 -0
 - data/lib/websocket/handshake/server.rb +3 -3
 - data/lib/websocket/version.rb +1 -1
 - data/spec/handshake/client_11_spec.rb +20 -0
 - data/spec/support/handshake_requests.rb +17 -0
 - data/websocket.gemspec +3 -2
 - metadata +8 -4
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 7ca690c7a42466b8cb035271b77010bdc7bf8a19
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 206ca9afa7b5606cb08b85ef66a8f186342d37b3
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 6b846fa2663e5f85415adc35e2aa39e0e7b21f844b444546c432a6b630c79d4aa4aabf5dbaf996c6334b80e1296b81a35a0935a51a9d0cfa55d6a748fb1762b7
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: cbf090a638401a094b7432f7a634ba7bc2f8fcd77b06e0407a8d2490f3236858368d619a6acf17296a715824c239b1c51beb5577597af91133e6c6472338c659
         
     | 
    
        data/.travis.yml
    CHANGED
    
    
    
        data/CHANGELOG.md
    CHANGED
    
    
    
        data/README.md
    CHANGED
    
    | 
         @@ -40,7 +40,7 @@ GET /demo HTTP/1.1\r 
     | 
|
| 
       40 
40 
     | 
    
         
             
            Upgrade: websocket\r
         
     | 
| 
       41 
41 
     | 
    
         
             
            Connection: Upgrade\r
         
     | 
| 
       42 
42 
     | 
    
         
             
            Host: example.com\r
         
     | 
| 
       43 
     | 
    
         
            -
             
     | 
| 
      
 43 
     | 
    
         
            +
            Origin: http://example.com\r
         
     | 
| 
       44 
44 
     | 
    
         
             
            Sec-WebSocket-Version: 13\r
         
     | 
| 
       45 
45 
     | 
    
         
             
            Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==\r
         
     | 
| 
       46 
46 
     | 
    
         
             
            \r
         
     | 
| 
         @@ -70,7 +70,7 @@ EOF 
     | 
|
| 
       70 
70 
     | 
    
         
             
                            # Connection: Upgrade
         
     | 
| 
       71 
71 
     | 
    
         
             
                            # Host: example.com
         
     | 
| 
       72 
72 
     | 
    
         
             
                            # Cookie: SESSIONID=1234
         
     | 
| 
       73 
     | 
    
         
            -
                            #  
     | 
| 
      
 73 
     | 
    
         
            +
                            # Origin: http://example.com
         
     | 
| 
       74 
74 
     | 
    
         
             
                            # Sec-WebSocket-Version: 13
         
     | 
| 
       75 
75 
     | 
    
         
             
                            # Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==
         
     | 
| 
       76 
76 
     | 
    
         | 
| 
         @@ -12,7 +12,7 @@ module WebSocket 
     | 
|
| 
       12 
12 
     | 
    
         
             
                #                   # Upgrade: websocket
         
     | 
| 
       13 
13 
     | 
    
         
             
                #                   # Connection: Upgrade
         
     | 
| 
       14 
14 
     | 
    
         
             
                #                   # Host: example.com
         
     | 
| 
       15 
     | 
    
         
            -
                #                   #  
     | 
| 
      
 15 
     | 
    
         
            +
                #                   # Origin: http://example.com
         
     | 
| 
       16 
16 
     | 
    
         
             
                #                   # Sec-WebSocket-Version: 13
         
     | 
| 
       17 
17 
     | 
    
         
             
                #                   # Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==
         
     | 
| 
       18 
18 
     | 
    
         
             
                #
         
     | 
| 
         @@ -117,7 +117,8 @@ module WebSocket 
     | 
|
| 
       117 
117 
     | 
    
         
             
                      when 75 then Handler::Client75.new(self)
         
     | 
| 
       118 
118 
     | 
    
         
             
                      when 76, 0 then Handler::Client76.new(self)
         
     | 
| 
       119 
119 
     | 
    
         
             
                      when 1..3  then Handler::Client01.new(self)
         
     | 
| 
       120 
     | 
    
         
            -
                      when 4.. 
     | 
| 
      
 120 
     | 
    
         
            +
                      when 4..10 then Handler::Client04.new(self)
         
     | 
| 
      
 121 
     | 
    
         
            +
                      when 11..17 then Handler::Client11.new(self)
         
     | 
| 
       121 
122 
     | 
    
         
             
                      else raise WebSocket::Error::Handshake::UnknownVersion
         
     | 
| 
       122 
123 
     | 
    
         
             
                    end
         
     | 
| 
       123 
124 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -7,6 +7,7 @@ module WebSocket 
     | 
|
| 
       7 
7 
     | 
    
         
             
                  autoload :Client,   "#{::WebSocket::ROOT}/websocket/handshake/handler/client"
         
     | 
| 
       8 
8 
     | 
    
         
             
                  autoload :Client01, "#{::WebSocket::ROOT}/websocket/handshake/handler/client01"
         
     | 
| 
       9 
9 
     | 
    
         
             
                  autoload :Client04, "#{::WebSocket::ROOT}/websocket/handshake/handler/client04"
         
     | 
| 
      
 10 
     | 
    
         
            +
                  autoload :Client11, "#{::WebSocket::ROOT}/websocket/handshake/handler/client11"
         
     | 
| 
       10 
11 
     | 
    
         
             
                  autoload :Client75, "#{::WebSocket::ROOT}/websocket/handshake/handler/client75"
         
     | 
| 
       11 
12 
     | 
    
         
             
                  autoload :Client76, "#{::WebSocket::ROOT}/websocket/handshake/handler/client76"
         
     | 
| 
       12 
13 
     | 
    
         | 
| 
         @@ -0,0 +1,22 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module WebSocket
         
     | 
| 
      
 2 
     | 
    
         
            +
              module Handshake
         
     | 
| 
      
 3 
     | 
    
         
            +
                module Handler
         
     | 
| 
      
 4 
     | 
    
         
            +
                  class Client11 < Client04
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
                    private
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
                    # @see WebSocket::Handshake::Handler::Base#handshake_keys
         
     | 
| 
      
 9 
     | 
    
         
            +
                    def handshake_keys
         
     | 
| 
      
 10 
     | 
    
         
            +
                      super.collect do |key_pair|
         
     | 
| 
      
 11 
     | 
    
         
            +
                        if key_pair[0] == 'Sec-WebSocket-Origin'
         
     | 
| 
      
 12 
     | 
    
         
            +
                          ['Origin', key_pair[1]]
         
     | 
| 
      
 13 
     | 
    
         
            +
                        else
         
     | 
| 
      
 14 
     | 
    
         
            +
                          key_pair
         
     | 
| 
      
 15 
     | 
    
         
            +
                        end
         
     | 
| 
      
 16 
     | 
    
         
            +
                      end
         
     | 
| 
      
 17 
     | 
    
         
            +
                    end
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
                  end
         
     | 
| 
      
 20 
     | 
    
         
            +
                end
         
     | 
| 
      
 21 
     | 
    
         
            +
              end
         
     | 
| 
      
 22 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -11,7 +11,7 @@ module WebSocket 
     | 
|
| 
       11 
11 
     | 
    
         
             
                #   Upgrade: websocket\r
         
     | 
| 
       12 
12 
     | 
    
         
             
                #   Connection: Upgrade\r
         
     | 
| 
       13 
13 
     | 
    
         
             
                #   Host: example.com\r
         
     | 
| 
       14 
     | 
    
         
            -
                #    
     | 
| 
      
 14 
     | 
    
         
            +
                #   Origin: http://example.com\r
         
     | 
| 
       15 
15 
     | 
    
         
             
                #   Sec-WebSocket-Version: 13\r
         
     | 
| 
       16 
16 
     | 
    
         
             
                #   Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==\r
         
     | 
| 
       17 
17 
     | 
    
         
             
                #   \r
         
     | 
| 
         @@ -54,7 +54,7 @@ module WebSocket 
     | 
|
| 
       54 
54 
     | 
    
         
             
                  #   Upgrade: websocket
         
     | 
| 
       55 
55 
     | 
    
         
             
                  #   Connection: Upgrade
         
     | 
| 
       56 
56 
     | 
    
         
             
                  #   Host: example.com
         
     | 
| 
       57 
     | 
    
         
            -
                  #    
     | 
| 
      
 57 
     | 
    
         
            +
                  #   Origin: http://example.com
         
     | 
| 
       58 
58 
     | 
    
         
             
                  #   Sec-WebSocket-Version: 13
         
     | 
| 
       59 
59 
     | 
    
         
             
                  #   Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==
         
     | 
| 
       60 
60 
     | 
    
         
             
                  #
         
     | 
| 
         @@ -156,7 +156,7 @@ module WebSocket 
     | 
|
| 
       156 
156 
     | 
    
         
             
                    @handler = case @version
         
     | 
| 
       157 
157 
     | 
    
         
             
                      when 75 then Handler::Server75.new(self)
         
     | 
| 
       158 
158 
     | 
    
         
             
                      when 76, 0..3 then Handler::Server76.new(self)
         
     | 
| 
       159 
     | 
    
         
            -
                      when 4.. 
     | 
| 
      
 159 
     | 
    
         
            +
                      when 4..17 then Handler::Server04.new(self)
         
     | 
| 
       160 
160 
     | 
    
         
             
                      else raise WebSocket::Error::Handshake::UnknownVersion
         
     | 
| 
       161 
161 
     | 
    
         
             
                    end
         
     | 
| 
       162 
162 
     | 
    
         
             
                  end
         
     | 
    
        data/lib/websocket/version.rb
    CHANGED
    
    
| 
         @@ -0,0 +1,20 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'spec_helper'
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            RSpec.describe 'Client draft 11 handshake' do
         
     | 
| 
      
 4 
     | 
    
         
            +
              let(:handshake) { WebSocket::Handshake::Client.new({ uri: 'ws://example.com/demo', origin: 'http://example.com', version: version }.merge(@request_params || {})) }
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
              let(:version) { 11 }
         
     | 
| 
      
 7 
     | 
    
         
            +
              let(:client_request) { client_handshake_11({ key: handshake.handler.send(:key), version: version }.merge(@request_params || {})) }
         
     | 
| 
      
 8 
     | 
    
         
            +
              let(:server_response) { server_handshake_11({ accept: handshake.handler.send(:accept) }.merge(@request_params || {})) }
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
              it_should_behave_like 'all client drafts'
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
              it 'should disallow client with invalid challenge' do
         
     | 
| 
      
 13 
     | 
    
         
            +
                @request_params = { accept: 'invalid' }
         
     | 
| 
      
 14 
     | 
    
         
            +
                handshake << server_response
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
                expect(handshake).to be_finished
         
     | 
| 
      
 17 
     | 
    
         
            +
                expect(handshake).not_to be_valid
         
     | 
| 
      
 18 
     | 
    
         
            +
                expect(handshake.error).to eql(:invalid_handshake_authentication)
         
     | 
| 
      
 19 
     | 
    
         
            +
              end
         
     | 
| 
      
 20 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -70,3 +70,20 @@ Sec-WebSocket-Accept: #{args[:accept] || 's3pPLMBiTxaQ9kYGzzhZRbK+xOo='}\r 
     | 
|
| 
       70 
70 
     | 
    
         
             
            \r
         
     | 
| 
       71 
71 
     | 
    
         
             
              EOF
         
     | 
| 
       72 
72 
     | 
    
         
             
            end
         
     | 
| 
      
 73 
     | 
    
         
            +
             
     | 
| 
      
 74 
     | 
    
         
            +
            def client_handshake_11(args = {})
         
     | 
| 
      
 75 
     | 
    
         
            +
              <<-EOF
         
     | 
| 
      
 76 
     | 
    
         
            +
            GET #{args[:path] || '/demo'}#{"?#{args[:query]}" if args[:query]} HTTP/1.1\r
         
     | 
| 
      
 77 
     | 
    
         
            +
            Upgrade: websocket\r
         
     | 
| 
      
 78 
     | 
    
         
            +
            Connection: Upgrade\r
         
     | 
| 
      
 79 
     | 
    
         
            +
            Host: #{args[:host] || 'example.com'}#{":#{args[:port]}" if args[:port]}\r
         
     | 
| 
      
 80 
     | 
    
         
            +
            #{(args[:headers] || {}).map{|key, value| "#{key}: #{value}\r\n"}.join('')}Origin: http://example.com\r
         
     | 
| 
      
 81 
     | 
    
         
            +
            Sec-WebSocket-Version: #{args[:version] || '4'}\r
         
     | 
| 
      
 82 
     | 
    
         
            +
            Sec-WebSocket-Key: #{args[:key] || 'dGhlIHNhbXBsZSBub25jZQ=='}\r
         
     | 
| 
      
 83 
     | 
    
         
            +
            \r
         
     | 
| 
      
 84 
     | 
    
         
            +
              EOF
         
     | 
| 
      
 85 
     | 
    
         
            +
            end
         
     | 
| 
      
 86 
     | 
    
         
            +
             
     | 
| 
      
 87 
     | 
    
         
            +
            def server_handshake_11(args = {})
         
     | 
| 
      
 88 
     | 
    
         
            +
              server_handshake_04(args)
         
     | 
| 
      
 89 
     | 
    
         
            +
            end
         
     | 
    
        data/websocket.gemspec
    CHANGED
    
    | 
         @@ -9,8 +9,9 @@ Gem::Specification.new do |s| 
     | 
|
| 
       9 
9 
     | 
    
         
             
              s.authors     = ["Bernard Potocki"]
         
     | 
| 
       10 
10 
     | 
    
         
             
              s.email       = ["bernard.potocki@imanel.org"]
         
     | 
| 
       11 
11 
     | 
    
         
             
              s.homepage    = "http://github.com/imanel/websocket-ruby"
         
     | 
| 
       12 
     | 
    
         
            -
              s.summary     =  
     | 
| 
       13 
     | 
    
         
            -
              s.description =  
     | 
| 
      
 12 
     | 
    
         
            +
              s.summary     = "Universal Ruby library to handle WebSocket protocol"
         
     | 
| 
      
 13 
     | 
    
         
            +
              s.description = "Universal Ruby library to handle WebSocket protocol"
         
     | 
| 
      
 14 
     | 
    
         
            +
              s.license     = "MIT"
         
     | 
| 
       14 
15 
     | 
    
         | 
| 
       15 
16 
     | 
    
         
             
              s.files         = `git ls-files`.split("\n")
         
     | 
| 
       16 
17 
     | 
    
         
             
              s.test_files    = `git ls-files -- {test,spec,features}/*`.split("\n")
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: websocket
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 1.2. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 1.2.2
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Bernard Potocki
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date:  
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2015-04-17 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies: []
         
     | 
| 
       13 
13 
     | 
    
         
             
            description: Universal Ruby library to handle WebSocket protocol
         
     | 
| 
       14 
14 
     | 
    
         
             
            email:
         
     | 
| 
         @@ -50,6 +50,7 @@ files: 
     | 
|
| 
       50 
50 
     | 
    
         
             
            - lib/websocket/handshake/handler/client.rb
         
     | 
| 
       51 
51 
     | 
    
         
             
            - lib/websocket/handshake/handler/client01.rb
         
     | 
| 
       52 
52 
     | 
    
         
             
            - lib/websocket/handshake/handler/client04.rb
         
     | 
| 
      
 53 
     | 
    
         
            +
            - lib/websocket/handshake/handler/client11.rb
         
     | 
| 
       53 
54 
     | 
    
         
             
            - lib/websocket/handshake/handler/client75.rb
         
     | 
| 
       54 
55 
     | 
    
         
             
            - lib/websocket/handshake/handler/client76.rb
         
     | 
| 
       55 
56 
     | 
    
         
             
            - lib/websocket/handshake/handler/server.rb
         
     | 
| 
         @@ -72,6 +73,7 @@ files: 
     | 
|
| 
       72 
73 
     | 
    
         
             
            - spec/frame/outgoing_75_spec.rb
         
     | 
| 
       73 
74 
     | 
    
         
             
            - spec/frame/outgoing_common_spec.rb
         
     | 
| 
       74 
75 
     | 
    
         
             
            - spec/handshake/client_04_spec.rb
         
     | 
| 
      
 76 
     | 
    
         
            +
            - spec/handshake/client_11_spec.rb
         
     | 
| 
       75 
77 
     | 
    
         
             
            - spec/handshake/client_75_spec.rb
         
     | 
| 
       76 
78 
     | 
    
         
             
            - spec/handshake/client_76_spec.rb
         
     | 
| 
       77 
79 
     | 
    
         
             
            - spec/handshake/server_04_spec.rb
         
     | 
| 
         @@ -87,7 +89,8 @@ files: 
     | 
|
| 
       87 
89 
     | 
    
         
             
            - spec/support/overwrites.rb
         
     | 
| 
       88 
90 
     | 
    
         
             
            - websocket.gemspec
         
     | 
| 
       89 
91 
     | 
    
         
             
            homepage: http://github.com/imanel/websocket-ruby
         
     | 
| 
       90 
     | 
    
         
            -
            licenses: 
     | 
| 
      
 92 
     | 
    
         
            +
            licenses:
         
     | 
| 
      
 93 
     | 
    
         
            +
            - MIT
         
     | 
| 
       91 
94 
     | 
    
         
             
            metadata: {}
         
     | 
| 
       92 
95 
     | 
    
         
             
            post_install_message: 
         
     | 
| 
       93 
96 
     | 
    
         
             
            rdoc_options: []
         
     | 
| 
         @@ -105,7 +108,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       105 
108 
     | 
    
         
             
                  version: '0'
         
     | 
| 
       106 
109 
     | 
    
         
             
            requirements: []
         
     | 
| 
       107 
110 
     | 
    
         
             
            rubyforge_project: 
         
     | 
| 
       108 
     | 
    
         
            -
            rubygems_version: 2. 
     | 
| 
      
 111 
     | 
    
         
            +
            rubygems_version: 2.4.5
         
     | 
| 
       109 
112 
     | 
    
         
             
            signing_key: 
         
     | 
| 
       110 
113 
     | 
    
         
             
            specification_version: 4
         
     | 
| 
       111 
114 
     | 
    
         
             
            summary: Universal Ruby library to handle WebSocket protocol
         
     | 
| 
         @@ -124,6 +127,7 @@ test_files: 
     | 
|
| 
       124 
127 
     | 
    
         
             
            - spec/frame/outgoing_75_spec.rb
         
     | 
| 
       125 
128 
     | 
    
         
             
            - spec/frame/outgoing_common_spec.rb
         
     | 
| 
       126 
129 
     | 
    
         
             
            - spec/handshake/client_04_spec.rb
         
     | 
| 
      
 130 
     | 
    
         
            +
            - spec/handshake/client_11_spec.rb
         
     | 
| 
       127 
131 
     | 
    
         
             
            - spec/handshake/client_75_spec.rb
         
     | 
| 
       128 
132 
     | 
    
         
             
            - spec/handshake/client_76_spec.rb
         
     | 
| 
       129 
133 
     | 
    
         
             
            - spec/handshake/server_04_spec.rb
         
     |