mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
Recognize and raise an exception on 405 Method Not Allowed responses. Closes #7692.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6864 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
@@ -24,6 +24,13 @@ module ActiveResource
|
||||
|
||||
class ServerError < ConnectionError; end # 5xx Server Error
|
||||
|
||||
# 405 Method Not Allowed
|
||||
class MethodNotAllowed < ClientError
|
||||
def allowed_methods
|
||||
@response['Allow'].split(',').map { |verb| verb.strip.downcase.to_sym }
|
||||
end
|
||||
end
|
||||
|
||||
# Class to handle connections to remote services.
|
||||
class Connection
|
||||
attr_reader :site
|
||||
@@ -99,6 +106,8 @@ module ActiveResource
|
||||
response
|
||||
when 404
|
||||
raise(ResourceNotFound.new(response))
|
||||
when 405
|
||||
raise(MethodNotAllowed.new(response))
|
||||
when 409
|
||||
raise(ResourceConflict.new(response))
|
||||
when 422
|
||||
|
||||
Reference in New Issue
Block a user