faye-websocket 0.4.6-java → 0.4.7-java

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.

Potentially problematic release.


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

@@ -50,7 +50,7 @@ module Faye
50
50
  @masking = options[:masking]
51
51
  @protocols = options[:protocols]
52
52
  @protocols = @protocols.split(/\s*,\s*/) if String === @protocols
53
-
53
+
54
54
  @ping_callbacks = {}
55
55
  end
56
56
 
@@ -89,11 +89,11 @@ module Faye
89
89
  def create_handshake
90
90
  Handshake.new(@socket.uri, @protocols)
91
91
  end
92
-
92
+
93
93
  def open?
94
94
  true
95
95
  end
96
-
96
+
97
97
  def parse(data)
98
98
  @reader.put(data.bytes.to_a)
99
99
  buffer = true
@@ -178,7 +178,7 @@ module Faye
178
178
 
179
179
  WebSocket.encode(frame)
180
180
  end
181
-
181
+
182
182
  def ping(message = '', &callback)
183
183
  @ping_callbacks[message] = callback if callback
184
184
  @socket.send(message, :ping)
@@ -1,8 +1,8 @@
1
1
  module Faye
2
2
  class WebSocket
3
-
3
+
4
4
  # http://www.w3.org/International/questions/qa-forms-utf-8.en.php
5
5
  UTF8_MATCH = /^([\x00-\x7F]|[\xC2-\xDF][\x80-\xBF]|\xE0[\xA0-\xBF][\x80-\xBF]|[\xE1-\xEC\xEE\xEF][\x80-\xBF]{2}|\xED[\x80-\x9F][\x80-\xBF]|\xF0[\x90-\xBF][\x80-\xBF]{2}|[\xF1-\xF3][\x80-\xBF]{3}|\xF4[\x80-\x8F][\x80-\xBF]{2})*$/
6
-
6
+
7
7
  end
8
8
  end
Binary file
@@ -9,15 +9,15 @@ WebSocketSteps = EM::RSpec.async_steps do
9
9
  @port = port
10
10
  EM.add_timer(0.1, &callback)
11
11
  end
12
-
12
+
13
13
  def stop(&callback)
14
14
  @server.stop
15
15
  EM.next_tick(&callback)
16
16
  end
17
-
17
+
18
18
  def open_socket(url, protocols, &callback)
19
19
  done = false
20
-
20
+
21
21
  resume = lambda do |open|
22
22
  unless done
23
23
  done = true
@@ -25,13 +25,13 @@ WebSocketSteps = EM::RSpec.async_steps do
25
25
  callback.call
26
26
  end
27
27
  end
28
-
28
+
29
29
  @ws = Faye::WebSocket::Client.new(url, protocols)
30
-
30
+
31
31
  @ws.onopen = lambda { |e| resume.call(true) }
32
32
  @ws.onclose = lambda { |e| resume.call(false) }
33
33
  end
34
-
34
+
35
35
  def close_socket(&callback)
36
36
  @ws.onclose = lambda do |e|
37
37
  @open = false
@@ -39,37 +39,37 @@ WebSocketSteps = EM::RSpec.async_steps do
39
39
  end
40
40
  @ws.close
41
41
  end
42
-
42
+
43
43
  def check_open(&callback)
44
44
  @open.should == true
45
45
  callback.call
46
46
  end
47
-
47
+
48
48
  def check_closed(&callback)
49
49
  @open.should == false
50
50
  callback.call
51
51
  end
52
-
52
+
53
53
  def check_protocol(protocol, &callback)
54
54
  @ws.protocol.should == protocol
55
55
  callback.call
56
56
  end
57
-
57
+
58
58
  def listen_for_message(&callback)
59
59
  @ws.add_event_listener('message', lambda { |e| @message = e.data })
60
60
  callback.call
61
61
  end
62
-
62
+
63
63
  def send_message(message, &callback)
64
64
  @ws.send(message)
65
65
  EM.add_timer(0.1, &callback)
66
66
  end
67
-
67
+
68
68
  def check_response(message, &callback)
69
69
  @message.should == message
70
70
  callback.call
71
71
  end
72
-
72
+
73
73
  def check_no_response(&callback)
74
74
  @message.should == nil
75
75
  callback.call
@@ -79,61 +79,56 @@ end
79
79
  describe Faye::WebSocket::Client do
80
80
  next if Faye::WebSocket.jruby?
81
81
  include WebSocketSteps
82
-
82
+
83
83
  let(:protocols) { ["foo", "echo"] }
84
84
  let(:plain_text_url) { "ws://0.0.0.0:8000/" }
85
85
  let(:secure_url) { "wss://0.0.0.0:8000/" }
86
-
87
- before do
88
- Thread.new { EM.run }
89
- sleep(0.1) until EM.reactor_running?
90
- end
91
-
86
+
92
87
  shared_examples_for "socket client" do
93
88
  it "can open a connection" do
94
89
  open_socket(socket_url, protocols)
95
90
  check_open
96
91
  check_protocol("echo")
97
92
  end
98
-
93
+
99
94
  it "cannot open a connection to the wrong host" do
100
95
  open_socket(blocked_url, protocols)
101
96
  check_closed
102
97
  end
103
-
98
+
104
99
  it "cannot open a connection with unacceptable protocols" do
105
100
  open_socket(socket_url, ["foo"])
106
101
  check_closed
107
102
  end
108
-
103
+
109
104
  it "can close the connection" do
110
105
  open_socket(socket_url, protocols)
111
106
  close_socket
112
107
  check_closed
113
108
  end
114
-
109
+
115
110
  describe "in the OPEN state" do
116
111
  before { open_socket(socket_url, protocols) }
117
-
112
+
118
113
  it "can send and receive messages" do
119
114
  listen_for_message
120
115
  send_message "I expect this to be echoed"
121
116
  check_response "I expect this to be echoed"
122
117
  end
123
-
118
+
124
119
  it "sends numbers as strings" do
125
120
  listen_for_message
126
121
  send_message 13
127
122
  check_response "13"
128
123
  end
129
124
  end
130
-
125
+
131
126
  describe "in the CLOSED state" do
132
127
  before do
133
128
  open_socket(socket_url, protocols)
134
129
  close_socket
135
130
  end
136
-
131
+
137
132
  it "cannot send and receive messages" do
138
133
  listen_for_message
139
134
  send_message "I expect this to be echoed"
@@ -141,38 +136,26 @@ describe Faye::WebSocket::Client do
141
136
  end
142
137
  end
143
138
  end
144
-
139
+
145
140
  describe "with a plain-text Thin server" do
146
141
  let(:socket_url) { plain_text_url }
147
142
  let(:blocked_url) { secure_url }
148
-
143
+
149
144
  before { server 8000, :thin, false }
150
- after { sync ; stop }
151
-
152
- it_should_behave_like "socket client"
153
- end
154
-
155
- describe "with a plain-text Rainbows server" do
156
- next if Faye::WebSocket.rbx?
157
-
158
- let(:socket_url) { plain_text_url }
159
- let(:blocked_url) { secure_url }
160
-
161
- before { server 8000, :rainbows, false }
162
- after { sync ; stop }
163
-
145
+ after { stop }
146
+
164
147
  it_should_behave_like "socket client"
165
148
  end
166
-
149
+
167
150
  describe "with a secure Thin server" do
168
151
  next if Faye::WebSocket.rbx?
169
-
152
+
170
153
  let(:socket_url) { secure_url }
171
154
  let(:blocked_url) { plain_text_url }
172
-
155
+
173
156
  before { server 8000, :thin, true }
174
- after { sync ; stop }
175
-
157
+ after { stop }
158
+
176
159
  it_should_behave_like "socket client"
177
160
  end
178
161
  end
@@ -7,38 +7,38 @@ shared_examples_for "draft-75 parser" do
7
7
  @web_socket.should_receive(:receive).with("Hello")
8
8
  parse [0x00, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0xff]
9
9
  end
10
-
10
+
11
11
  it "parses multiple frames from the same packet" do
12
12
  @web_socket.should_receive(:receive).with("Hello").exactly(2)
13
13
  parse [0x00, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0xff, 0x00, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0xff]
14
14
  end
15
-
15
+
16
16
  it "parses text frames beginning 0x00-0x7F" do
17
17
  @web_socket.should_receive(:receive).with("Hello")
18
18
  parse [0x66, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0xff]
19
19
  end
20
-
20
+
21
21
  it "ignores frames with a length header" do
22
22
  @web_socket.should_not_receive(:receive)
23
23
  parse [0x80, 0x05, 0x48, 0x65, 0x6c, 0x6c, 0x6f]
24
24
  end
25
-
25
+
26
26
  it "parses text following an ignored block" do
27
27
  @web_socket.should_receive(:receive).with("Hello")
28
28
  parse [0x80, 0x02, 0x48, 0x65, 0x00, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0xff]
29
29
  end
30
-
30
+
31
31
  it "parses multibyte text frames" do
32
32
  @web_socket.should_receive(:receive).with(encode "Apple = ")
33
33
  parse [0x00, 0x41, 0x70, 0x70, 0x6c, 0x65, 0x20, 0x3d, 0x20, 0xef, 0xa3, 0xbf, 0xff]
34
34
  end
35
-
35
+
36
36
  it "parses frames received in several packets" do
37
37
  @web_socket.should_receive(:receive).with(encode "Apple = ")
38
38
  parse [0x00, 0x41, 0x70, 0x70, 0x6c, 0x65]
39
39
  parse [0x20, 0x3d, 0x20, 0xef, 0xa3, 0xbf, 0xff]
40
40
  end
41
-
41
+
42
42
  it "parses fragmented frames" do
43
43
  @web_socket.should_receive(:receive).with("Hello")
44
44
  parse [0x00, 0x48, 0x65, 0x6c]
@@ -4,21 +4,21 @@ require "spec_helper"
4
4
 
5
5
  describe Faye::WebSocket::Draft75Parser do
6
6
  include EncodingHelper
7
-
7
+
8
8
  before do
9
9
  @web_socket = mock Faye::WebSocket
10
10
  @parser = Faye::WebSocket::Draft75Parser.new(@web_socket)
11
11
  end
12
-
12
+
13
13
  describe :parse do
14
14
  it_should_behave_like "draft-75 parser"
15
15
  end
16
-
16
+
17
17
  describe :frame do
18
18
  it "returns the given string formatted as a WebSocket frame" do
19
19
  bytes(@parser.frame "Hello").should == [0x00, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0xff]
20
20
  end
21
-
21
+
22
22
  it "encodes multibyte characters correctly" do
23
23
  message = encode "Apple = "
24
24
  bytes(@parser.frame message).should == [0x00, 0x41, 0x70, 0x70, 0x6c, 0x65, 0x20, 0x3d, 0x20, 0xef, 0xa3, 0xbf, 0xff]
@@ -4,27 +4,27 @@ require "spec_helper"
4
4
 
5
5
  describe Faye::WebSocket::Draft76Parser do
6
6
  include EncodingHelper
7
-
7
+
8
8
  before do
9
9
  @web_socket = mock Faye::WebSocket
10
10
  @parser = Faye::WebSocket::Draft76Parser.new(@web_socket)
11
11
  @parser.instance_eval { @handshake_complete = true }
12
12
  end
13
-
13
+
14
14
  describe :parse do
15
15
  it_should_behave_like "draft-75 parser"
16
-
16
+
17
17
  it "closes the socket if a close frame is received" do
18
18
  @web_socket.should_receive(:close)
19
19
  parse [0xFF, 0x00]
20
20
  end
21
21
  end
22
-
22
+
23
23
  describe :frame do
24
24
  it "returns the given string formatted as a WebSocket frame" do
25
25
  bytes(@parser.frame "Hello").should == [0x00, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0xff]
26
26
  end
27
-
27
+
28
28
  it "encodes multibyte characters correctly" do
29
29
  message = encode "Apple = "
30
30
  bytes(@parser.frame message).should == [0x00, 0x41, 0x70, 0x70, 0x6c, 0x65, 0x20, 0x3d, 0x20, 0xef, 0xa3, 0xbf, 0xff]
data/spec/spec_helper.rb CHANGED
@@ -18,11 +18,11 @@ module EncodingHelper
18
18
  message.force_encoding("UTF-8") :
19
19
  message
20
20
  end
21
-
21
+
22
22
  def bytes(string)
23
23
  string.bytes.to_a
24
24
  end
25
-
25
+
26
26
  def parse(bytes)
27
27
  @parser.parse(bytes.pack('C*'))
28
28
  end
@@ -36,7 +36,7 @@ class EchoServer
36
36
  end
37
37
  socket.rack_response
38
38
  end
39
-
39
+
40
40
  def listen(port, backend, ssl = false)
41
41
  case backend
42
42
  when :rainbows
@@ -60,7 +60,7 @@ class EchoServer
60
60
  end
61
61
  end
62
62
  end
63
-
63
+
64
64
  def stop
65
65
  @server.stop
66
66
  end
metadata CHANGED
@@ -1,137 +1,177 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: faye-websocket
3
- version: !ruby/object:Gem::Version
4
- prerelease:
5
- version: 0.4.6
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.4.7
6
6
  platform: java
7
- authors:
8
- - James Coglan
9
- autorequire:
7
+ authors:
8
+ - James Coglan
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
-
13
- date: 2012-07-09 00:00:00 Z
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
16
- name: eventmachine
17
- prerelease: false
18
- requirement: &id001 !ruby/object:Gem::Requirement
19
- none: false
20
- requirements:
21
- - - ">="
22
- - !ruby/object:Gem::Version
23
- version: 0.12.0
24
- type: :runtime
25
- version_requirements: *id001
26
- - !ruby/object:Gem::Dependency
27
- name: rack
28
- prerelease: false
29
- requirement: &id002 !ruby/object:Gem::Requirement
30
- none: false
31
- requirements:
32
- - - ">="
33
- - !ruby/object:Gem::Version
34
- version: "0"
35
- type: :development
36
- version_requirements: *id002
37
- - !ruby/object:Gem::Dependency
38
- name: rake-compiler
39
- prerelease: false
40
- requirement: &id003 !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
43
- - - ">="
44
- - !ruby/object:Gem::Version
45
- version: "0"
46
- type: :development
47
- version_requirements: *id003
48
- - !ruby/object:Gem::Dependency
49
- name: rspec
50
- prerelease: false
51
- requirement: &id004 !ruby/object:Gem::Requirement
52
- none: false
53
- requirements:
54
- - - ~>
55
- - !ruby/object:Gem::Version
56
- version: 2.8.0
57
- type: :development
58
- version_requirements: *id004
59
- description:
12
+ date: 2013-02-15 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: eventmachine
16
+ version_requirements: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ">="
19
+ - !ruby/object:Gem::Version
20
+ version: 0.12.0
21
+ none: false
22
+ requirement: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 0.12.0
27
+ none: false
28
+ prerelease: false
29
+ type: :runtime
30
+ - !ruby/object:Gem::Dependency
31
+ name: progressbar
32
+ version_requirements: !ruby/object:Gem::Requirement
33
+ requirements:
34
+ - - ">="
35
+ - !ruby/object:Gem::Version
36
+ version: !binary |-
37
+ MA==
38
+ none: false
39
+ requirement: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: !binary |-
44
+ MA==
45
+ none: false
46
+ prerelease: false
47
+ type: :development
48
+ - !ruby/object:Gem::Dependency
49
+ name: rack
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: !binary |-
55
+ MA==
56
+ none: false
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: !binary |-
62
+ MA==
63
+ none: false
64
+ prerelease: false
65
+ type: :development
66
+ - !ruby/object:Gem::Dependency
67
+ name: rake-compiler
68
+ version_requirements: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: !binary |-
73
+ MA==
74
+ none: false
75
+ requirement: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: !binary |-
80
+ MA==
81
+ none: false
82
+ prerelease: false
83
+ type: :development
84
+ - !ruby/object:Gem::Dependency
85
+ name: rspec
86
+ version_requirements: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: !binary |-
91
+ MA==
92
+ none: false
93
+ requirement: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - ">="
96
+ - !ruby/object:Gem::Version
97
+ version: !binary |-
98
+ MA==
99
+ none: false
100
+ prerelease: false
101
+ type: :development
102
+ description:
60
103
  email: jcoglan@gmail.com
61
104
  executables: []
62
-
63
105
  extensions: []
64
-
65
- extra_rdoc_files:
66
- - README.rdoc
67
- files:
68
- - README.rdoc
69
- - CHANGELOG.txt
70
- - ext/faye_websocket_mask/faye_websocket_mask.c
71
- - ext/faye_websocket_mask/FayeWebsocketMaskService.java
72
- - ext/faye_websocket_mask/extconf.rb
73
- - lib/faye/eventsource.rb
74
- - lib/faye/websocket.rb
75
- - lib/faye/adapters/goliath.rb
76
- - lib/faye/adapters/rainbows.rb
77
- - lib/faye/adapters/rainbows_client.rb
78
- - lib/faye/adapters/thin.rb
79
- - lib/faye/websocket/adapter.rb
80
- - lib/faye/websocket/api.rb
81
- - lib/faye/websocket/client.rb
82
- - lib/faye/websocket/draft75_parser.rb
83
- - lib/faye/websocket/draft76_parser.rb
84
- - lib/faye/websocket/hybi_parser.rb
85
- - lib/faye/websocket/utf8_match.rb
86
- - lib/faye/websocket/api/event.rb
87
- - lib/faye/websocket/api/event_target.rb
88
- - lib/faye/websocket/hybi_parser/handshake.rb
89
- - lib/faye/websocket/hybi_parser/stream_reader.rb
90
- - examples/app.rb
91
- - examples/autobahn_client.rb
92
- - examples/client.rb
93
- - examples/config.ru
94
- - examples/haproxy.conf
95
- - examples/server.rb
96
- - examples/sse.html
97
- - examples/ws.html
98
- - spec/rainbows.conf
99
- - spec/server.crt
100
- - spec/server.key
101
- - spec/spec_helper.rb
102
- - spec/faye/websocket/client_spec.rb
103
- - spec/faye/websocket/draft75_parser_examples.rb
104
- - spec/faye/websocket/draft75_parser_spec.rb
105
- - spec/faye/websocket/draft76_parser_spec.rb
106
- - spec/faye/websocket/hybi_parser_spec.rb
107
- - lib/faye_websocket_mask.jar
106
+ extra_rdoc_files:
107
+ - README.rdoc
108
+ files:
109
+ - README.rdoc
110
+ - CHANGELOG.txt
111
+ - ext/faye_websocket_mask/faye_websocket_mask.c
112
+ - ext/faye_websocket_mask/FayeWebsocketMaskService.java
113
+ - ext/faye_websocket_mask/extconf.rb
114
+ - lib/faye/eventsource.rb
115
+ - lib/faye/websocket.rb
116
+ - lib/faye/adapters/goliath.rb
117
+ - lib/faye/adapters/rainbows.rb
118
+ - lib/faye/adapters/rainbows_client.rb
119
+ - lib/faye/adapters/thin.rb
120
+ - lib/faye/websocket/adapter.rb
121
+ - lib/faye/websocket/api.rb
122
+ - lib/faye/websocket/client.rb
123
+ - lib/faye/websocket/draft75_parser.rb
124
+ - lib/faye/websocket/draft76_parser.rb
125
+ - lib/faye/websocket/hybi_parser.rb
126
+ - lib/faye/websocket/utf8_match.rb
127
+ - lib/faye/websocket/api/event.rb
128
+ - lib/faye/websocket/api/event_target.rb
129
+ - lib/faye/websocket/hybi_parser/handshake.rb
130
+ - lib/faye/websocket/hybi_parser/stream_reader.rb
131
+ - examples/app.rb
132
+ - examples/autobahn_client.rb
133
+ - examples/client.rb
134
+ - examples/config.ru
135
+ - examples/haproxy.conf
136
+ - examples/server.rb
137
+ - examples/sse.html
138
+ - examples/ws.html
139
+ - spec/rainbows.conf
140
+ - spec/server.crt
141
+ - spec/server.key
142
+ - spec/spec_helper.rb
143
+ - spec/faye/websocket/client_spec.rb
144
+ - spec/faye/websocket/draft75_parser_examples.rb
145
+ - spec/faye/websocket/draft75_parser_spec.rb
146
+ - spec/faye/websocket/draft76_parser_spec.rb
147
+ - spec/faye/websocket/hybi_parser_spec.rb
148
+ - lib/faye_websocket_mask.jar
108
149
  homepage: http://github.com/faye/faye-websocket-ruby
109
150
  licenses: []
110
-
111
- post_install_message:
112
- rdoc_options:
113
- - --main
114
- - README.rdoc
115
- require_paths:
116
- - lib
117
- required_ruby_version: !ruby/object:Gem::Requirement
151
+ post_install_message:
152
+ rdoc_options:
153
+ - "--main"
154
+ - README.rdoc
155
+ require_paths:
156
+ - lib
157
+ required_ruby_version: !ruby/object:Gem::Requirement
158
+ requirements:
159
+ - - ">="
160
+ - !ruby/object:Gem::Version
161
+ version: !binary |-
162
+ MA==
118
163
  none: false
119
- requirements:
120
- - - ">="
121
- - !ruby/object:Gem::Version
122
- version: "0"
123
- required_rubygems_version: !ruby/object:Gem::Requirement
164
+ required_rubygems_version: !ruby/object:Gem::Requirement
165
+ requirements:
166
+ - - ">="
167
+ - !ruby/object:Gem::Version
168
+ version: !binary |-
169
+ MA==
124
170
  none: false
125
- requirements:
126
- - - ">="
127
- - !ruby/object:Gem::Version
128
- version: "0"
129
171
  requirements: []
130
-
131
- rubyforge_project:
132
- rubygems_version: 1.8.15
133
- signing_key:
172
+ rubyforge_project:
173
+ rubygems_version: 1.8.24
174
+ signing_key:
134
175
  specification_version: 3
135
176
  summary: Standards-compliant WebSocket server and client
136
177
  test_files: []
137
-