corntrace-rack-contrib 1.0.2.2 → 1.0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/rack/contrib.rb +1 -1
- data/lib/rack/contrib/jsonp.rb +1 -1
- data/rack-contrib.gemspec +1 -1
- data/test/spec_rack_jsonp.rb +2 -2
- metadata +3 -3
data/lib/rack/contrib.rb
CHANGED
data/lib/rack/contrib/jsonp.rb
CHANGED
@@ -67,7 +67,7 @@ module Rack
|
|
67
67
|
# status code to 200. That because the jsonp's implemetation could not handler
|
68
68
|
# http status code when error occured, which could be meaningful in webservice.
|
69
69
|
def translate_error_code(status, response)
|
70
|
-
if status
|
70
|
+
if status / 100 == 4 || status / 100 == 5
|
71
71
|
[200, [%Q|{"errorCode":#{status}}|]]
|
72
72
|
else
|
73
73
|
[status, response]
|
data/rack-contrib.gemspec
CHANGED
@@ -3,7 +3,7 @@ Gem::Specification.new do |s|
|
|
3
3
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
4
4
|
|
5
5
|
s.name = 'corntrace-rack-contrib'
|
6
|
-
s.version = '1.0.2.
|
6
|
+
s.version = '1.0.2.3'
|
7
7
|
s.date = '2010-07-18'
|
8
8
|
|
9
9
|
s.description = "Contributed Rack Middleware and Utilities"
|
data/test/spec_rack_jsonp.rb
CHANGED
@@ -55,11 +55,11 @@ context "Rack::JSONP" do
|
|
55
55
|
|
56
56
|
specify "should write status code to response and set status to 200 if status is 40x or 50x" do
|
57
57
|
callback = 'foo'
|
58
|
-
app = lambda { |env| [
|
58
|
+
app = lambda { |env| [401, {'Content-Type' => 'application/json'}, [""]] }
|
59
59
|
request = Rack::MockRequest.env_for("/", :params => "foo=bar&callback=#{callback}")
|
60
60
|
status, headers, body = Rack::JSONP.new(app).call(request)
|
61
61
|
status.should.equal 200
|
62
|
-
body.should.equal ["#{callback}({\"errorCode\":
|
62
|
+
body.should.equal ["#{callback}({\"errorCode\":401})"]
|
63
63
|
end
|
64
64
|
|
65
65
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: corntrace-rack-contrib
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 81
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
9
|
- 2
|
10
|
-
-
|
11
|
-
version: 1.0.2.
|
10
|
+
- 3
|
11
|
+
version: 1.0.2.3
|
12
12
|
platform: ruby
|
13
13
|
authors:
|
14
14
|
- Kevin Fu
|