rack-jsonp-tools 0.3.5 → 0.3.6
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/rack/jsonp/callback.rb +1 -2
- data/lib/rack/jsonp/status_wrapper.rb +2 -2
- data/rack-jsonp-tools.gemspec +1 -1
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.6
|
data/lib/rack/jsonp/callback.rb
CHANGED
@@ -15,8 +15,7 @@ module Rack
|
|
15
15
|
|
16
16
|
# Call original app
|
17
17
|
status, headers, @body = @app.call(env)
|
18
|
-
|
19
|
-
if headers["Content-Type"] == "application/json"
|
18
|
+
if headers["Content-Type"].to_s.start_with?("application/json")
|
20
19
|
@pre, @post = "#{callback}(", ")"
|
21
20
|
headers["Content-Length"] = (@pre.size + headers["Content-Length"].to_i + @post.size).to_s
|
22
21
|
headers["Content-Type"] = "application/javascript" # Set proper content type as per RFC4329
|
@@ -6,12 +6,12 @@ module Rack
|
|
6
6
|
@app = app
|
7
7
|
end
|
8
8
|
|
9
|
-
def call(env)
|
9
|
+
def call(env)
|
10
10
|
if env["jsonp.callback"]
|
11
11
|
# Call original app
|
12
12
|
status, headers, @body = @app.call(env)
|
13
13
|
|
14
|
-
if headers["Content-Type"]
|
14
|
+
if headers["Content-Type"].to_s.start_with?("application/json")
|
15
15
|
@pre, @post = '{"body":', ', "status":' + status.to_s + '}'
|
16
16
|
headers["Content-Length"] = (@pre.size + headers["Content-Length"].to_i + @post.size).to_s
|
17
17
|
[status, headers, self]
|
data/rack-jsonp-tools.gemspec
CHANGED