rack-jsonr 0.2.6 → 0.2.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/rack/jsonr/jsonr.rb +6 -1
- data/lib/rack/jsonr/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZTEzNzM0ZDBmMDhkYmQ2ZDIzODIxNzZhMWUyYjIzODZkMGFlMGI1Yg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
M2VhZTNiNDYzYzcyMzkyOTY2NzE1Yzg3ZjcwZGU2ZDFmMWY2NTdiMw==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZmFiN2IwMmVlYTExNjNlMDAzOTUzODdmMTY1NTNjMDdkOTM1NWU2NTVhMmQ0
|
10
|
+
YWI2Mjk0MDNkMjkzN2Y5MzE1NWQzMDRlMGFhMGE4NThmODEzOWRkZTMxOGY1
|
11
|
+
N2ZlN2M3Njc1MWUyNDA5MGExYjM5NTMyMmQ1OTAxZTkxMzM5NjU=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MDFhNTE1MjA1ZjZjNWY0OTQ2NzllNmE5ODgyNzk0ZWI1YTI4ODE2YWQyMmIy
|
14
|
+
ZTNmYWE1MTQ0Y2UwOGYyZDUyNDYxNDAyM2ZhYjEwOTM3YTJlYThlOTI4MGY3
|
15
|
+
OTc1ODk5YWVjMzg1NzkwNmVlMWM3ZWZhNTk2NzJkMGE4NTBhYmY=
|
data/lib/rack/jsonr/jsonr.rb
CHANGED
@@ -72,10 +72,15 @@ module Rack
|
|
72
72
|
# Formats the JSONP padding to include body, headers and http status
|
73
73
|
#
|
74
74
|
def format_jsonp(callback, status, headers, response, x_headers={}, body='')
|
75
|
+
content_is_text = headers['Content-Type'].to_s.include?('text/html') ? true : false
|
75
76
|
headers['Content-Type'] = 'application/javascript;charset=utf-8'
|
76
77
|
headers.each {|k,v| x_headers[k] = v if (k =~ /^X-.+/i) }
|
77
78
|
response.each {|v| body << v.to_s }
|
78
|
-
|
79
|
+
if body.nil? or body == ''
|
80
|
+
body = 'null'
|
81
|
+
elsif content_is_text
|
82
|
+
body = body.to_json
|
83
|
+
end
|
79
84
|
["#{callback}(#{body}, #{status}, #{x_headers.to_json})"]
|
80
85
|
end
|
81
86
|
|
data/lib/rack/jsonr/version.rb
CHANGED