message_bus 1.0.4 → 1.0.5
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 +4 -4
- data/CHANGELOG +5 -0
- data/lib/message_bus/client.rb +7 -3
- data/lib/message_bus/rack/middleware.rb +6 -1
- data/lib/message_bus/version.rb +1 -1
- data/spec/lib/middleware_spec.rb +6 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7aa504726b847a3d9b1721a32bd87ae01d8e4cdc
|
4
|
+
data.tar.gz: 9c0567bf68c1404e4d5b7b48721011fed464504c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ecb0d74d4dc76fdab724e8263644e33d7958fad8649bb9e386258456b19e3320ab8fe60e8d0a23c657b1c9988560c32005e8bc070285400b7f41266e6fb51025
|
7
|
+
data.tar.gz: 209f41516198cb4cd4d9deffd2a386281754e3decf565f4585159ca7ef55289935242e9db3e063aaa6d68f897da407e3d991243771b8f52c7fe5f52e60c396eb
|
data/CHANGELOG
CHANGED
data/lib/message_bus/client.rb
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
class MessageBus::Client
|
2
|
-
attr_accessor :client_id, :user_id, :group_ids, :connect_time,
|
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
|
-
@
|
103
|
-
|
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"]]
|
data/lib/message_bus/version.rb
CHANGED
data/spec/lib/middleware_spec.rb
CHANGED
@@ -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
|