cryx-g5k 0.2.10 → 0.2.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. data/VERSION.yml +1 -1
  2. data/lib/g5k/rack/jsonp.rb +11 -3
  3. metadata +2 -2
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :minor: 2
3
- :patch: 10
3
+ :patch: 11
4
4
  :major: 0
@@ -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.10
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-03-27 00:00:00 -07:00
12
+ date: 2009-04-02 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15