faye-websocket 0.6.3 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


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

@@ -1,3 +1,8 @@
1
+ ### 0.7.0 / 2013-09-09
2
+
3
+ * Allow the server to send custom headers with EventSource responses
4
+
5
+
1
6
  ### 0.6.3 / 2013-08-04
2
7
 
3
8
  * Stop implicitly depending on Rack 1.4
data/README.md CHANGED
@@ -249,17 +249,23 @@ The `EventSource` object exposes the following properties:
249
249
  When you initialize an EventSource with `Faye::EventSource.new`, you can pass
250
250
  configuration options after the `env` parameter. Available options are:
251
251
 
252
+ * <b>`:headers`</b> is a hash containing custom headers to be set on the
253
+ EventSource response.
252
254
  * <b>`:retry`</b> is a number that tells the client how long (in seconds) it
253
255
  should wait after a dropped connection before attempting to reconnect.
254
256
  * <b>`:ping`</b> is a number that tells the server how often (in seconds) to
255
257
  send 'ping' packets to the client to keep the connection open, to defeat
256
258
  timeouts set by proxies. The client will ignore these messages.
257
259
 
258
- For example, this creates a connection that pings every 15 seconds and is
259
- retryable every 10 seconds if the connection is broken:
260
+ For example, this creates a connection that allows access from any origin, pings
261
+ every 15 seconds and is retryable every 10 seconds if the connection is broken:
260
262
 
261
263
  ```ruby
262
- es = Faye::EventSource.new(es, :ping => 15, :retry => 10)
264
+ es = Faye::EventSource.new(es,
265
+ :headers => {'Access-Control-Allow-Origin' => '*'},
266
+ :ping => 15,
267
+ :retry => 10
268
+ )
263
269
  ```
264
270
 
265
271
  You can send a ping message at any time by calling `es.ping`. Unlike WebSocket
@@ -31,6 +31,11 @@ module Faye
31
31
 
32
32
  @ready_state = WebSocket::API::CONNECTING
33
33
 
34
+ headers = ::WebSocket::Driver::Headers.new
35
+ if options[:headers]
36
+ options[:headers].each { |k,v| headers[k] = v }
37
+ end
38
+
34
39
  if callback = @env['async.callback']
35
40
  callback.call([101, {}, @stream])
36
41
  end
@@ -39,7 +44,8 @@ module Faye
39
44
  "Content-Type: text/event-stream\r\n" +
40
45
  "Cache-Control: no-cache, no-store\r\n" +
41
46
  "Connection: close\r\n" +
42
- "\r\n\r\n" +
47
+ headers.to_s +
48
+ "\r\n" +
43
49
  "retry: #{ (@retry * 1000).floor }\r\n\r\n")
44
50
 
45
51
  EventMachine.next_tick { open }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: faye-websocket
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.3
4
+ version: 0.7.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-08-04 00:00:00.000000000 Z
12
+ date: 2013-09-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: eventmachine
@@ -34,7 +34,7 @@ dependencies:
34
34
  requirements:
35
35
  - - ! '>='
36
36
  - !ruby/object:Gem::Version
37
- version: 0.2.0
37
+ version: 0.3.0
38
38
  type: :runtime
39
39
  prerelease: false
40
40
  version_requirements: !ruby/object:Gem::Requirement
@@ -42,7 +42,7 @@ dependencies:
42
42
  requirements:
43
43
  - - ! '>='
44
44
  - !ruby/object:Gem::Version
45
- version: 0.2.0
45
+ version: 0.3.0
46
46
  - !ruby/object:Gem::Dependency
47
47
  name: progressbar
48
48
  requirement: !ruby/object:Gem::Requirement