Welcome to the "trac"-ing site of soap4r!
[soap4r] [httpclient] [openpgp4u] [pkcs1] [logger] [csv] [vtr]

Ticket #280 (closed enhancement: fixed)

Opened 2 years ago

Last modified 2 years ago

Follow HTTP redirection even with net/http

Reported by: nahi Assigned to: nahi
Priority: normal Milestone: 1.5.6
Component: soap4r Version: 1.5
Keywords: Cc:

Description

from ruby-list

SOAP4Rにて、 Net::HTTP 用のリダイレクトを実装するパッチです:

--- lib/soap/netHttpClient.rb-	2006-10-17 21:48:51.334345544 +0900
+++ lib/soap/netHttpClient.rb	2006-10-17 21:55:57.540552352 +0900
@@ -83,7 +83,7 @@
     # no persistent connection.  ignored.
   end
 
-  def post(url, req_body, header = {})
+  def post(url, req_body, header = {}, redirect_count = 10)
     unless url.is_a?(URI)
       url = URI.parse(url)
     end
@@ -92,7 +92,16 @@
     res = start(url) { |http|
       http.post(url.request_uri, req_body, extra)
     }
-    Response.new(res)
+    case res
+    when Net::HTTPRedirection 
+      if redirect_count > 0
+        post(res['location'], req_body, header, redirect_count - 1) 
+      else
+	raise ArgumentError.new("Too many redirects")
+      end
+    else
+      Response.new(res)
+    end
   end
 
   def get_content(url, header = {})

Change History

10/22/06 14:16:55 changed by nahi

  • status changed from new to closed.
  • resolution set to fixed.

(In [1743]) * HTTP redirection even with net/http. merged a patch from Uekawa-san on ruby-list. closes #280.