message_bus 1.0.4 → 1.0.5

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 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: ea4f0356599eb2162116ae4f248a3cef4fa01273
4
- data.tar.gz: af4ca7315e84cd65d5ec9116a1aa61b6f3c69b85
3
+ metadata.gz: 7aa504726b847a3d9b1721a32bd87ae01d8e4cdc
4
+ data.tar.gz: 9c0567bf68c1404e4d5b7b48721011fed464504c
5
5
  SHA512:
6
- metadata.gz: 94b77a368cc509c56978ae656d171309a0b448fc42e0976b961483a022fa9953965b0a64fa8e9e28d1b5af46f8a31a9c4cc8f7fb04b42477e5608341e23a53cf
7
- data.tar.gz: 61b01a3d60b13b2853c13f454e24046118fe131291896bbb0b9ff9f181ae2a2c481abdbd184640bbc91f65f51951cd0257e5bbaf4f0715f8703292b4d28b7e1c
6
+ metadata.gz: ecb0d74d4dc76fdab724e8263644e33d7958fad8649bb9e386258456b19e3320ab8fe60e8d0a23c657b1c9988560c32005e8bc070285400b7f41266e6fb51025
7
+ data.tar.gz: 209f41516198cb4cd4d9deffd2a386281754e3decf565f4585159ca7ef55289935242e9db3e063aaa6d68f897da407e3d991243771b8f52c7fe5f52e60c396eb
data/CHANGELOG CHANGED
@@ -1,3 +1,8 @@
1
+
2
+ 23-09-2014
3
+ - Version 1.0.5
4
+ - Fix: missing custom headers from long polls
5
+
1
6
  23-09-2014
2
7
  - Version 1.0.4
3
8
  - Change: MessageBus.access_control_allow_origin_lookup to extra_response_headers_lookup
@@ -1,5 +1,8 @@
1
1
  class MessageBus::Client
2
- attr_accessor :client_id, :user_id, :group_ids, :connect_time, :subscribed_sets, :site_id, :cleanup_timer, :async_response, :io
2
+ attr_accessor :client_id, :user_id, :group_ids, :connect_time,
3
+ :subscribed_sets, :site_id, :cleanup_timer,
4
+ :async_response, :io, :headers
5
+
3
6
  def initialize(opts)
4
7
  self.client_id = opts[:client_id]
5
8
  self.user_id = opts[:user_id]
@@ -99,8 +102,9 @@ class MessageBus::Client
99
102
  def write_and_close(data)
100
103
  if @io
101
104
  @io.write("HTTP/1.1 200 OK\r\n")
102
- @io.write("Content-Type: application/json; charset=utf-8\r\n")
103
- @io.write("Cache-Control: must-revalidate, private, max-age=0\r\n")
105
+ @headers.each do |k,v|
106
+ @io.write("#{k}: #{v}\r\n")
107
+ end
104
108
  @io.write("Content-Length: #{data.bytes.to_a.length}\r\n")
105
109
  @io.write("Connection: close\r\n")
106
110
  @io.write("\r\n")
@@ -85,8 +85,12 @@ class MessageBus::Rack::Middleware
85
85
 
86
86
  backlog = client.backlog
87
87
  headers = {}
88
+
88
89
  headers["Cache-Control"] = "must-revalidate, private, max-age=0"
89
- headers["Content-Type"] ="application/json; charset=utf-8"
90
+ headers["Content-Type"] = "application/json; charset=utf-8"
91
+ headers["Pragma"] = "no-cache"
92
+ headers["Expires"] = "0"
93
+
90
94
  if @bus.extra_response_headers_lookup
91
95
  @bus.extra_response_headers_lookup.call(env).each do |k,v|
92
96
  headers[k] = v
@@ -109,6 +113,7 @@ class MessageBus::Rack::Middleware
109
113
  elsif long_polling && env['rack.hijack'] && @bus.rack_hijack_enabled?
110
114
  io = env['rack.hijack'].call
111
115
  client.io = io
116
+ client.headers = headers
112
117
 
113
118
  add_client_with_timeout(client)
114
119
  [418, {}, ["I'm a teapot, undefined in spec"]]
@@ -1,3 +1,3 @@
1
1
  module MessageBus
2
- VERSION = "1.0.4"
2
+ VERSION = "1.0.5"
3
3
  end
@@ -55,6 +55,10 @@ describe MessageBus::Rack::Middleware do
55
55
  middleware = @async_middleware
56
56
  bus = @bus
57
57
 
58
+ @bus.extra_response_headers_lookup do |env|
59
+ {"FOO" => "BAR"}
60
+ end
61
+
58
62
  Thread.new do
59
63
  wait_for(2000) {middleware.in_async?}
60
64
  bus.publish "/foo", "םוֹלשָׁ"
@@ -66,6 +70,8 @@ describe MessageBus::Rack::Middleware do
66
70
  parsed = JSON.parse(last_response.body)
67
71
  parsed.length.should == 1
68
72
  parsed[0]["data"].should == "םוֹלשָׁ"
73
+
74
+ last_response.headers["FOO"].should == "BAR"
69
75
  end
70
76
 
71
77
  it "should timeout within its alloted slot" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: message_bus
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam Saffron