[rubygem-dynect_rest] Patch to fix redirect handling during long API calls https://github.com/adamhjk/dynect_rest/pull/25

Russell Harrison rharrison at fedoraproject.org
Fri Aug 30 15:29:42 UTC 2013


commit 7781bdfbd942b3a23f0b29970f82960d813ebd4e
Author: Russell Harrison <rharrison at fedoraproject.org>
Date:   Tue Aug 27 15:22:13 2013 -0400

    Patch to fix redirect handling during long API calls
    https://github.com/adamhjk/dynect_rest/pull/25

 dynect_rest-fix_redirect_handling.patch |   26 ++++++++++++++++++++++++++
 rubygem-dynect_rest.spec                |    8 +++++++-
 2 files changed, 33 insertions(+), 1 deletions(-)
---
diff --git a/dynect_rest-fix_redirect_handling.patch b/dynect_rest-fix_redirect_handling.patch
new file mode 100644
index 0000000..98bc31b
--- /dev/null
+++ b/dynect_rest-fix_redirect_handling.patch
@@ -0,0 +1,26 @@
+diff --git a/lib/dynect_rest.rb b/lib/dynect_rest.rb
+index 9a5b94e..e8bf480 100644
+--- a/lib/dynect_rest.rb
++++ b/lib/dynect_rest.rb
+@@ -33,11 +33,11 @@ class DynectRest
+   # @param [String] The zone you are going to be editing
+   # @param [Boolean] Whether to connect immediately or not - runs login for you
+   # @param [Boolean] Verbosity
+-  def initialize(customer_name, user_name, password, zone=nil, connect=true, verbose=false)
++  def initialize(customer_name, user_name, password, zone=nil, connect=true, verbose=false, max_redirects=10)
+     @customer_name = customer_name
+     @user_name = user_name
+     @password = password
+-    @rest = RestClient::Resource.new('https://api2.dynect.net/REST/', :headers => { :content_type => 'application/json' })
++    @rest = RestClient::Resource.new('https://api2.dynect.net/REST/', :headers => { :content_type => 'application/json' }, :max_redirects=>max_redirects)
+     @zone = zone 
+     @verbose = verbose
+     login if connect
+@@ -196,6 +196,7 @@ def api_request(&block)
+         puts "I have #{e.inspect} with #{e.http_code}"
+       end
+       if e.http_code == 307
++        e.response.sub!('/REST/','') if e.response =~ /^\/REST\//
+         get(e.response)
+       end
+       e.response
diff --git a/rubygem-dynect_rest.spec b/rubygem-dynect_rest.spec
index 8a39ec8..14bb3ed 100644
--- a/rubygem-dynect_rest.spec
+++ b/rubygem-dynect_rest.spec
@@ -4,7 +4,7 @@
 
 Name:           rubygem-%{gem_name}
 Version:        0.4.3
-Release:        6%{?dist}
+Release:        7%{?dist}
 Summary:        Dynect REST API library
 
 Group:          Development/Languages
@@ -12,6 +12,8 @@ Group:          Development/Languages
 License:        ASL 2.0
 URL:            http://github.com/adamhjk/dynect_rest
 Source0:        http://rubygems.org/gems/%{gem_name}-%{version}.gem
+# https://github.com/adamhjk/dynect_rest/pull/25
+Patch0:         dynect_rest-fix_redirect_handling.patch
 
 BuildArch:      noarch
 %if 0%{?fedora} >= 19
@@ -47,6 +49,7 @@ Documentation for %{name}
 gem unpack %{SOURCE0}
 
 %setup -q -D -T -n  %{gem_name}-%{version}
+%patch0 -p1
 
 gem spec %{SOURCE0} -l --ruby > %{gem_name}.gemspec
 
@@ -91,6 +94,9 @@ rm -f %{buildroot}%{gem_instdir}/.rspec
 %doc %{gem_instdir}/VERSION
 
 %changelog
+* Tue Aug 27 2013 Russell Harrison <rharrison at fedoraproject.org> 0.4.3-7
+- Patch to fix redirect handling during long API calls.
+
 * Sun Aug 04 2013 Fedora Release Engineering <rel-eng at lists.fedoraproject.org> - 0.4.3-6
 - Rebuilt for https://fedoraproject.org/wiki/Fedora_20_Mass_Rebuild
 


More information about the scm-commits mailing list