* gc.c (set_heaps_increment): fix memory allocation strategy by
[ruby-svn.git] / sample / openssl / wget.rb
blobee637204dbe5a0169ace95daaa49f533cebe3b1c
1 #!/usr/bin/env ruby
3 require 'net/https'
4 require 'optparse'
6 options = ARGV.getopts('C:')
8 cert_store = options["C"]
10 uri = URI.parse(ARGV[0])
11 if proxy = ENV['HTTP_PROXY']
12   prx_uri = URI.parse(proxy)
13   prx_host = prx_uri.host
14   prx_port = prx_uri.port
15 end
17 h = Net::HTTP.new(uri.host, uri.port, prx_host, prx_port)
18 h.set_debug_output($stderr) if $DEBUG
19 if uri.scheme == "https"
20   h.use_ssl = true
21   if cert_store
22     if File.directory?(cert_store)
23       h.ca_path = cert_store
24     else
25       h.ca_file = cert_store
26     end
27   end
28 end
30 path = uri.path.empty? ? "/" : uri.path
31 h.get2(path){|resp|
32   STDERR.puts h.peer_cert.inspect if h.peer_cert
33   print resp.body