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

Changeset 1496

Show
Ignore:
Timestamp:
04/17/05 12:47:49 (4 years ago)
Author:
nahi
Message:

pull out http configuration loader as a new file. let wsdl/xmlSchema/importer use it.

Files:

Legend:

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

    r1388 r1496  
    88 
    99require 'soap/soap' 
    10 require 'soap/property
     10require 'soap/httpconfigloader
    1111begin 
    1212  require 'stringio' 
     
    119119 
    120120  def set_options 
    121     @client.proxy = @options["proxy"] 
    122     @options.add_hook("proxy") do |key, value| 
    123       @client.proxy = value 
    124     end 
    125     @client.no_proxy = @options["no_proxy"] 
    126     @options.add_hook("no_proxy") do |key, value| 
    127       @client.no_proxy = value 
    128     end 
    129     if @client.respond_to?(:protocol_version=) 
    130       @client.protocol_version = @options["protocol_version"] 
    131       @options.add_hook("protocol_version") do |key, value| 
    132         @client.protocol_version = value 
    133       end 
    134     end 
    135     set_cookie_store_file(@options["cookie_store_file"]) 
    136     @options.add_hook("cookie_store_file") do |key, value| 
    137       set_cookie_store_file(value) 
    138     end 
     121    HTTPConfigLoader.set_options(@client, @options) 
    139122    @charset = @options["charset"] || XSD::Charset.charset_label($KCODE) 
    140123    @options.add_hook("charset") do |key, value| 
     
    146129      @client.debug_dev = @wiredump_dev 
    147130    end 
    148     ssl_config = @options["ssl_config"] ||= ::SOAP::Property.new 
    149     set_ssl_config(ssl_config) 
    150     ssl_config.add_hook(true) do |key, value| 
    151       set_ssl_config(ssl_config) 
    152     end 
    153     basic_auth = @options["basic_auth"] ||= ::SOAP::Property.new 
    154     set_basic_auth(basic_auth) 
    155     basic_auth.add_hook do |key, value| 
    156       set_basic_auth(basic_auth) 
    157     end 
    158     @options.add_hook("connect_timeout") do |key, value| 
    159       @client.connect_timeout = value 
    160     end 
    161     @options.add_hook("send_timeout") do |key, value| 
    162       @client.send_timeout = value 
    163     end 
    164     @options.add_hook("receive_timeout") do |key, value| 
    165       @client.receive_timeout = value 
    166     end 
     131    set_cookie_store_file(@options["cookie_store_file"]) 
     132    @options.add_hook("cookie_store_file") do |key, value| 
     133      set_cookie_store_file(value) 
     134    end 
     135    ssl_config = @options["ssl_config"] 
     136    basic_auth = @options["basic_auth"] 
    167137    @options.lock(true) 
    168138    ssl_config.unlock 
     
    170140  end 
    171141 
    172   def set_basic_auth(basic_auth) 
    173     basic_auth.values.each do |url, userid, passwd| 
    174       @client.set_basic_auth(url, userid, passwd) 
    175     end 
    176   end 
    177  
    178142  def set_cookie_store_file(value) 
    179143    @cookie_store = value 
    180144    @client.set_cookie_store(@cookie_store) if @cookie_store 
    181   end 
    182  
    183   def set_ssl_config(ssl_config) 
    184     ssl_config.each do |key, value| 
    185       cfg = @client.ssl_config 
    186       case key 
    187       when 'client_cert' 
    188         cfg.client_cert = cert_from_file(value) 
    189       when 'client_key' 
    190         cfg.client_key = key_from_file(value) 
    191       when 'client_ca' 
    192         cfg.client_ca = value 
    193       when 'ca_path' 
    194         cfg.set_trust_ca(value) 
    195       when 'ca_file' 
    196         cfg.set_trust_ca(value) 
    197       when 'crl' 
    198         cfg.set_crl(value) 
    199       when 'verify_mode' 
    200         cfg.verify_mode = ssl_config_int(value) 
    201       when 'verify_depth' 
    202         cfg.verify_depth = ssl_config_int(value) 
    203       when 'options' 
    204         cfg.options = value 
    205       when 'ciphers' 
    206         cfg.ciphers = value 
    207       when 'verify_callback' 
    208         cfg.verify_callback = value 
    209       when 'cert_store' 
    210         cfg.cert_store = value 
    211       else 
    212         raise ArgumentError.new("unknown ssl_config property #{key}") 
    213       end 
    214     end 
    215   end 
    216  
    217   def ssl_config_int(value) 
    218     if value.nil? or value.empty? 
    219       nil 
    220     else 
    221       begin 
    222         Integer(value) 
    223       rescue ArgumentError 
    224         ::SOAP::Property::Util.const_from_name(value) 
    225       end 
    226     end 
    227   end 
    228  
    229   def cert_from_file(filename) 
    230     OpenSSL::X509::Certificate.new(File.open(filename) { |f| f.read }) 
    231   end 
    232  
    233   def key_from_file(filename) 
    234     OpenSSL::PKey::RSA.new(File.open(filename) { |f| f.read }) 
    235145  end 
    236146 
  • trunk/lib/wsdl/xmlSchema/importer.rb

    r1488 r1496  
    77 
    88 
    9 require 'soap/property
     9require 'soap/httpconfigloader
    1010require 'wsdl/xmlSchema/parser' 
    1111 
     
    4747    else 
    4848      client = web_client.new(nil, "WSDL4R") 
     49      client.proxy = ::SOAP::Env::HTTP_PROXY 
     50      client.no_proxy = ::SOAP::Env::NO_PROXY 
    4951      if opt = ::SOAP::Property.loadproperty(::SOAP::PropertyName) 
    50         client.proxy = opt["client.protocol.http.proxy"] 
    51         client.no_proxy = opt["client.protocol.http.no_proxy"] 
     52        ::SOAP::HTTPConfigLoader.set_options(client, opt["client.protocol.http"]) 
    5253      end 
    53       client.proxy ||= ::SOAP::Env::HTTP_PROXY 
    54       client.no_proxy ||= ::SOAP::Env::NO_PROXY 
    5554      content = client.get_content(location) 
    5655    end