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

Changeset 1743

Show
Ignore:
Timestamp:
10/22/06 14:16:51 (2 years ago)
Author:
nahi
Message:
  • HTTP redirection even with net/http. merged a patch from Uekawa-san on ruby-list. closes #280.
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lib/soap/netHttpClient.rb

    r1703 r1743  
    8585 
    8686  def post(url, req_body, header = {}) 
    87     unless url.is_a?(URI) 
    88       url = URI.parse(url) 
    89     end 
    90     extra = header.dup 
    91     extra['User-Agent'] = @agent if @agent 
    92     res = start(url) { |http| 
    93       http.post(url.request_uri, req_body, extra) 
    94     } 
    95     Response.new(res) 
     87    post_redirect(url, req_body, header, 10) 
    9688  end 
    9789 
     
    109101 
    110102private 
     103 
     104  def post_redirect(url, req_body, header, redirect_count) 
     105    unless url.is_a?(URI) 
     106      url = URI.parse(url) 
     107    end 
     108    extra = header.dup 
     109    extra['User-Agent'] = @agent if @agent 
     110    res = start(url) { |http| 
     111      http.post(url.request_uri, req_body, extra) 
     112    } 
     113    case res 
     114    when Net::HTTPRedirection  
     115      if redirect_count > 0 
     116        post_redirect(res['location'], req_body, header, 
     117          redirect_count - 1)  
     118      else 
     119       raise ArgumentError.new("Too many redirects") 
     120      end 
     121    else 
     122      Response.new(res) 
     123    end 
     124  end 
    111125 
    112126  def start(url)