diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2007-05-26 20:57:08 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2007-05-26 20:57:08 +0000 |
commit | 849038ee514b6ddfb0876c293c5b87e3d960f0bf (patch) | |
tree | 8dd96b8208b18ab5276554e81bc595aa5c7363fe /activeresource/lib | |
parent | 404a357013f6a544692841770b03a1ccf0b57ea7 (diff) | |
download | rails-849038ee514b6ddfb0876c293c5b87e3d960f0bf.tar.gz rails-849038ee514b6ddfb0876c293c5b87e3d960f0bf.tar.bz2 rails-849038ee514b6ddfb0876c293c5b87e3d960f0bf.zip |
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
Diffstat (limited to 'activeresource/lib')
-rw-r--r-- | activeresource/lib/active_resource/connection.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/activeresource/lib/active_resource/connection.rb b/activeresource/lib/active_resource/connection.rb index bb3993512e..ef4d92451c 100644 --- a/activeresource/lib/active_resource/connection.rb +++ b/activeresource/lib/active_resource/connection.rb @@ -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 |