rack-jsonp-tools 0.3.3 → 0.3.4

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.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.3
1
+ 0.3.4
@@ -16,14 +16,11 @@ module Rack
16
16
  # Call original app
17
17
  status, headers, @body = @app.call(env)
18
18
 
19
- # Fix content length if present
20
- content_length = headers["Content-Length"].to_i
21
-
22
- if (200...300).include?(status) && content_length > 0
19
+ if headers["Content-Type"] == "application/json"
23
20
  @pre, @post = "#{callback}(", ")"
24
- headers["Content-Length"] = (@pre.size + content_length + @post.size).to_s
21
+ headers["Content-Length"] = (@pre.size + headers["Content-Length"].to_i + @post.size).to_s
25
22
  headers["Content-Type"] = "application/javascript" # Set proper content type as per RFC4329
26
- [200, headers, self] # Override status
23
+ [200, headers, self]
27
24
  else
28
25
  [status, headers, @body]
29
26
  end
@@ -11,13 +11,10 @@ module Rack
11
11
  # Call original app
12
12
  status, headers, @body = @app.call(env)
13
13
 
14
- # Fix content length if present
15
- content_length = headers["Content-Length"].to_i
16
-
17
- if (200...300).include?(status) && content_length > 0
14
+ if headers["Content-Type"] == "application/json"
18
15
  @pre, @post = '{"body": ', ', "status": ' + status.to_s + '}'
19
- headers["Content-Length"] = (@pre.size + content_length + @post.size).to_s
20
- [status, headers, self] # Override status
16
+ headers["Content-Length"] = (@pre.size + headers["Content-Length"].to_i + @post.size).to_s
17
+ [status, headers, self]
21
18
  else
22
19
  [status, headers, @body]
23
20
  end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{rack-jsonp-tools}
8
- s.version = "0.3.3"
8
+ s.version = "0.3.4"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Jacek Becela"]
12
- s.date = %q{2010-06-28}
12
+ s.date = %q{2010-06-29}
13
13
  s.description = %q{A collection of rack middlewares helping you add JSONP to your app}
14
14
  s.email = %q{jacek.becela@gmail.com}
15
15
  s.files = [
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 3
8
- - 3
9
- version: 0.3.3
8
+ - 4
9
+ version: 0.3.4
10
10
  platform: ruby
11
11
  authors:
12
12
  - Jacek Becela
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-06-28 00:00:00 +02:00
17
+ date: 2010-06-29 00:00:00 +02:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency