xray-rails 0.1.11 → 0.1.12
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/xray/middleware.rb +13 -2
- data/lib/xray/version.rb +1 -1
- metadata +4 -4
data/lib/xray/middleware.rb
CHANGED
@@ -35,6 +35,7 @@ module Xray
|
|
35
35
|
# Inject xray.js and friends if this is a successful HTML response
|
36
36
|
else
|
37
37
|
status, headers, response = @app.call(env)
|
38
|
+
|
38
39
|
if html_headers?(status, headers) && body = response_body(response)
|
39
40
|
body = body.sub(/<body[^>]*>/) { "#{$~}\n#{xray_bar}" }
|
40
41
|
# Inject js script tags if assets are unbundled
|
@@ -42,9 +43,19 @@ module Xray
|
|
42
43
|
append_js!(body, 'jquery', 'xray')
|
43
44
|
append_js!(body, 'backbone', 'xray-backbone')
|
44
45
|
end
|
45
|
-
|
46
|
+
content_length = body.bytesize.to_s
|
47
|
+
# Modifying the original response obj maintains compatibility with other middlewares
|
48
|
+
if ActionDispatch::Response === response
|
49
|
+
response.body = [body]
|
50
|
+
response.header['Content-Length'] = content_length
|
51
|
+
response.to_a
|
52
|
+
else
|
53
|
+
headers['Content-Length'] = content_length
|
54
|
+
[status, headers, [body]]
|
55
|
+
end
|
56
|
+
else
|
57
|
+
[status, headers, response]
|
46
58
|
end
|
47
|
-
[status, headers, (body ? [body] : response)]
|
48
59
|
end
|
49
60
|
end
|
50
61
|
|
data/lib/xray/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: xray-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.12
|
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-12-
|
12
|
+
date: 2013-12-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -205,7 +205,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
205
205
|
version: '0'
|
206
206
|
segments:
|
207
207
|
- 0
|
208
|
-
hash:
|
208
|
+
hash: 3612644589838496871
|
209
209
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
210
210
|
none: false
|
211
211
|
requirements:
|
@@ -214,7 +214,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
214
214
|
version: '0'
|
215
215
|
segments:
|
216
216
|
- 0
|
217
|
-
hash:
|
217
|
+
hash: 3612644589838496871
|
218
218
|
requirements: []
|
219
219
|
rubyforge_project:
|
220
220
|
rubygems_version: 1.8.23
|