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

Changeset 1593

Show
Ignore:
Timestamp:
07/23/05 22:47:24 (3 years ago)
Author:
nahi
Message:

follow HTTP redirect only if using http-access2. closes #125.

Files:

Legend:

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

    r1583 r1593  
    3535  RUBY_VERSION_STRING = "ruby #{ RUBY_VERSION } (#{ RUBY_RELEASE_DATE }) [#{ RUBY_PLATFORM }]" 
    3636 
     37  RETRYABLE = (Client == HTTPAccess2::Client) 
     38 
    3739  class ConnectionData 
    3840    attr_accessor :send_string 
     
    162164    @wiredump_dev << "Wire dump:\n\n" if @wiredump_dev 
    163165    begin 
    164       res = @client.post(endpoint_url, send_string, extra) 
     166      retry_count = 0 
     167      while true 
     168        res = @client.post(endpoint_url, send_string, extra) 
     169        if RETRYABLE and HTTP::Status.redirect?(res.status) 
     170          retry_count += 1 
     171          if retry_count >= 10 
     172            raise HTTPStreamError.new("redirect count exceeded") 
     173          end 
     174          endpoint_url = res.header["location"][0] 
     175          puts "redirected to #{endpoint_url}" if $DEBUG 
     176        else 
     177          break 
     178        end 
     179      end 
    165180    rescue 
    166181      @client.reset(endpoint_url)