From 095a7f18df0bf05b0518e12c1a91ebbaac6b48db Mon Sep 17 00:00:00 2001 From: Julien Kirch Date: Sat, 18 Dec 2010 18:15:04 +0100 Subject: [PATCH] code style + history --- history.md | 1 + lib/restclient/abstract_response.rb | 4 +++- lib/restclient/request.rb | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/history.md b/history.md index da134ec..ac54bf8 100644 --- a/history.md +++ b/history.md @@ -7,6 +7,7 @@ - cookies set in a response should be kept in a redirect - HEAD requests should process parameters just like GET (patch provided by Rob Eanes) - Exception message should never be nil (patch provided by Michael Klett) +- Limit number of redirections (patch provided by Chris Dinn) # 1.6.0 diff --git a/lib/restclient/abstract_response.rb b/lib/restclient/abstract_response.rb index 94be717..3519680 100644 --- a/lib/restclient/abstract_response.rb +++ b/lib/restclient/abstract_response.rb @@ -67,7 +67,9 @@ module RestClient end args[:url] = url if request - raise MaxRedirectsReached if request.max_redirects == 0 + if request.max_redirects == 0 + raise MaxRedirectsReached + end args[:password] = request.password args[:user] = request.user args[:headers] = request.headers diff --git a/lib/restclient/request.rb b/lib/restclient/request.rb index 41e078d..9d4e656 100644 --- a/lib/restclient/request.rb +++ b/lib/restclient/request.rb @@ -17,6 +17,7 @@ module RestClient # * :cookies will replace possible cookies in the :headers # * :user and :password for basic auth, will be replaced by a user/password available in the :url # * :raw_response return a low-level RawResponse instead of a Response + # * :max_redirects maximum number of redirections (default to 10) # * :verify_ssl enable ssl verification, possible values are constants from OpenSSL::SSL # * :timeout and :open_timeout # * :ssl_client_cert, :ssl_client_key, :ssl_ca_file