Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

remove HTTPException

  • Loading branch information...
commit b7abd6216fec445b3bc4f89ae819844d178ec161 1 parent 5a0fbe7
Thom Mahoney & Josh Lane authored
View
2  lib/rack-idempotent.rb
@@ -11,7 +11,6 @@ class Rack::Idempotent
autoload :DefaultRescue, 'rack-idempotent/default_rescue'
# Exceptions
- autoload :HTTPException, 'rack-idempotent/http_exception'
autoload :RetryLimitExceeded, 'rack-idempotent/retry_limit_exceeded'
autoload :Retryable, 'rack-idempotent/retryable'
@@ -33,7 +32,6 @@ def call(env)
begin
status, headers, body = @app.call(env.dup)
- raise HTTPException.new(status, headers, body, request) if status >= 400
response = Rack::Response.new(body, status, headers)
next if rescue_policy.call({:response => response, :request => request})
return [status, headers, body]
View
9 lib/rack-idempotent/default_rescue.rb
@@ -9,14 +9,7 @@ def call(options={})
method = nil
if exception
- if IDEMPOTENT_ERROR_CLASSES.include?(exception.class)
- return true
- elsif exception.class == Rack::Idempotent::HTTPException
- status = exception.status
- method = exception.request.env["REQUEST_METHOD"]
- else
- return false
- end
+ return IDEMPOTENT_ERROR_CLASSES.include?(exception.class)
end
unless status && method
View
10 lib/rack-idempotent/http_exception.rb
@@ -1,10 +0,0 @@
-class Rack::Idempotent::HTTPException < StandardError
- attr_reader :status, :headers, :body, :request
- def initialize(status, headers, body, request)
- @status, @headers, @body, @request = status, headers, body, request
- end
-
- def to_s
- @status.to_s
- end
-end
View
16 spec/rack-idempotent/default_rescue_spec.rb
@@ -32,13 +32,8 @@
[200, 201, 301, 302, 400, 401, 403, 404, 500].each do |status|
it "should not retry GET requests that result in #{status}" do
TestCall.errors = [status]
- begin
- client.get("http://example.org/")
- status.should < 400
- rescue Rack::Idempotent::HTTPException => e
- e.status.should == status
- e.status.should >= 400
- end
+ client.get("http://example.org/")
+ status.should == status
RecordRequests.requests.count.should == 1
end
end
@@ -60,11 +55,8 @@
it "should not retry POST requests that result in #{status}" do
TestCall.errors = [status]
begin
- client.post("http://example.org/")
- status.should < 400
- rescue Rack::Idempotent::HTTPException => e
- e.status.should == status
- e.status.should >= 400
+ response = client.post("http://example.org/")
+ response.status.should == status
end
RecordRequests.requests.count.should == 1
end
View
4 spec/rack-idempotent_spec.rb
@@ -171,9 +171,7 @@
it 'does not retry a POST if the status is 408' do
TestCall.errors = [408]
- lambda {
- client.post("http://example.org/")
- }.should raise_exception Rack::Idempotent::HTTPException
+ client.post("http://example.org/")
RecordRequests.requests.count.should == 1

0 comments on commit b7abd62

Please sign in to comment.
Something went wrong with that request. Please try again.