message_bus 1.0.1 → 1.0.2

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

Potentially problematic release.


This version of message_bus might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ef40442bfe83abc9cd8b0a7be99fcb4e27f76a56
4
- data.tar.gz: cfb98a433dd8a32d7dc405ec4e95c59297046bae
3
+ metadata.gz: 3e700c3c80050d48c9178c002eff99ffc42e93ea
4
+ data.tar.gz: 1397d55bf69953ac861e8dc36bc217958daeab20
5
5
  SHA512:
6
- metadata.gz: 8c8a9b6a258c7dbdbc35b3b675a3b67b278060a95249f8c2ac8de3a1761654941a7251e62267901ecb75ae8af7bb6fd6c08c3a6e5b4ff74f41325bcdd9ea3960
7
- data.tar.gz: 401b34231fc26a549cb4443e7306b9675b1457d07ec717375882a58818d74f418350441421381b6d055d64774703d1d9e462892e9d0585adc139cf847e0617cb
6
+ metadata.gz: dac0e42ad4de5e15c56b8906c98cf55448bffbc5e5ea15615cbbb0c37d231cf423b79fab5130717e94900aa0777924ed8277db7a5b14dfc2e55ca581069d60a8
7
+ data.tar.gz: 1688685a11b6f70b027064ad97ea2a220a97ca424d1294fe379ef75a009793e7a7079c7e217a22ea9853ecfa7c4832e0f8f24a632d858db87380558ce39f241b
data/CHANGELOG CHANGED
@@ -1,3 +1,7 @@
1
+ 23-09-2014
2
+ - Version 1.0.2
3
+ - Feature: MessageBus.access_control_allow_origin to control origin header
4
+
1
5
  23-09-2014
2
6
  - Version 1.0.1
3
7
  - Feature: $.ajax dependency can be passed in.
@@ -87,6 +87,7 @@ class MessageBus::Rack::Middleware
87
87
  headers = {}
88
88
  headers["Cache-Control"] = "must-revalidate, private, max-age=0"
89
89
  headers["Content-Type"] ="application/json; charset=utf-8"
90
+ headers["Access-Control-Allow-Origin"] = @bus.access_control_allow_origin if @bus.access_control_allow_origin
90
91
 
91
92
  ensure_reactor
92
93
 
@@ -113,8 +114,9 @@ class MessageBus::Rack::Middleware
113
114
  response = Thin::AsyncResponse.new(env)
114
115
  end
115
116
 
116
- response.headers["Cache-Control"] = "must-revalidate, private, max-age=0".freeze
117
- response.headers["Content-Type"] ="application/json; charset=utf-8".freeze
117
+ headers.each do |k,v|
118
+ response.headers[k] = v
119
+ end
118
120
  response.status = 200
119
121
 
120
122
  client.async_response = response
@@ -1,3 +1,3 @@
1
1
  module MessageBus
2
- VERSION = "1.0.1"
2
+ VERSION = "1.0.2"
3
3
  end
data/lib/message_bus.rb CHANGED
@@ -141,6 +141,14 @@ module MessageBus::Implementation
141
141
  @is_admin_lookup
142
142
  end
143
143
 
144
+ def access_control_allow_origin=(origin)
145
+ @access_control_allow_origin = origin
146
+ end
147
+
148
+ def access_control_allow_origin
149
+ @access_control_allow_origin
150
+ end
151
+
144
152
  def client_filter(channel, &blk)
145
153
  @client_filters ||= {}
146
154
  @client_filters[channel] = blk if blk
@@ -162,6 +162,20 @@ describe MessageBus::Rack::Middleware do
162
162
  @bus.long_polling_enabled = false
163
163
  end
164
164
 
165
+ it "should include access control headers" do
166
+ @bus.access_control_allow_origin = "http://rainbows.com"
167
+
168
+ client_id = "ABCD"
169
+
170
+ # client always keeps a list of channels with last message id they got on each
171
+ post "/message-bus/#{client_id}", {
172
+ '/foo' => nil,
173
+ '/bar' => nil
174
+ }
175
+
176
+ last_response.headers["Access-Control-Allow-Origin"].should == "http://rainbows.com"
177
+ end
178
+
165
179
  it "should respond with a 200 to a subscribe" do
166
180
  client_id = "ABCD"
167
181
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: message_bus
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam Saffron
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-23 00:00:00.000000000 Z
11
+ date: 2014-10-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack