cryx-g5k 0.2.10 → 0.2.11
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION.yml +1 -1
- data/lib/g5k/rack/jsonp.rb +11 -3
- metadata +2 -2
data/VERSION.yml
CHANGED
data/lib/g5k/rack/jsonp.rb
CHANGED
@@ -25,7 +25,11 @@ module Rack
|
|
25
25
|
status, headers, response = @app.call(env)
|
26
26
|
if callback
|
27
27
|
response = pad(callback, response)
|
28
|
-
headers['Content-Length'] = response.length.to_s
|
28
|
+
headers['Content-Length'] = response.first.length.to_s
|
29
|
+
elsif headers['Content-Type'] =~ /application\/json/
|
30
|
+
# add a \n after the response if this is a json (not JSONP) response
|
31
|
+
response = carriage_return(response)
|
32
|
+
headers['Content-Length'] = response.first.length.to_s
|
29
33
|
end
|
30
34
|
[status, headers, response]
|
31
35
|
end
|
@@ -39,8 +43,12 @@ module Rack
|
|
39
43
|
#
|
40
44
|
def pad(callback, response, body = "")
|
41
45
|
response.each{ |s| body << s }
|
42
|
-
"#{callback}(#{body})"
|
46
|
+
["#{callback}(#{body})"]
|
47
|
+
end
|
48
|
+
|
49
|
+
def carriage_return(response, body = "")
|
50
|
+
response.each{ |s| body << s }
|
51
|
+
["#{body}\n"]
|
43
52
|
end
|
44
|
-
|
45
53
|
end
|
46
54
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cryx-g5k
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cyril Rohr
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-04-02 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|