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

Changeset 1057

Show
Ignore:
Timestamp:
11/21/03 00:34:36 (5 years ago)
Author:
nahi
Message:

Add https support. Patched by Oliver M. Bolzer.

Files:

Legend:

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

    r1052 r1057  
    2525 
    2626class NetHttpClient 
     27 
     28  SSLEnabled = begin 
     29      require 'net/https' 
     30      true 
     31    rescue LoadError 
     32      false 
     33    end 
    2734 
    2835  attr_accessor :proxy 
     
    8794 
    8895  def start(url) 
    89     proxy_host = proxy_port = nil 
    90     unless no_proxy?(url) 
    91       proxy_host = @proxy.host 
    92       proxy_port = @proxy.port 
    93     end 
    94     http = Net::HTTP::Proxy(proxy_host, proxy_port).new(url.host, url.port) 
    95     http.set_debug_output(@debug_dev) if http.respond_to?(:set_debug_output) 
     96    http = create_connection(url) 
    9697    response = nil 
    9798    http.start { |worker| 
     
    101102    @debug_dev << response.body if @debug_dev 
    102103    response 
     104  end 
     105 
     106  def create_connection(url) 
     107    proxy_host = proxy_port = nil 
     108    unless no_proxy?(url) 
     109      proxy_host = @proxy.host 
     110      proxy_port = @proxy.port 
     111    end 
     112    http = Net::HTTP::Proxy(proxy_host, proxy_port).new(url.host, url.port) 
     113    if http.respond_to?(:set_debug_output) 
     114      http.set_debug_output(@debug_dev) 
     115    end 
     116    case url 
     117    when URI::HTTPS 
     118      if SSLEnabled 
     119        http.use_ssl = true 
     120      else 
     121        raise RuntimeError.new("Cannot connect to #{url} (OpenSSL is not installed.)") 
     122      end 
     123    when URI::HTTP 
     124      # OK 
     125    else 
     126      raise RuntimeError.new("Cannot connect to #{url} (Not HTTP.)") 
     127    end 
     128    http 
    103129  end 
    104130