On Tue, Oct 08, 2002 at 10:56:46AM +0900, Eric Hodel wrote:
> Jim Freeze (jim / freeze.org) wrote:
> 
> > Ok, that worked fine. Now how do I get net/http to do that?
> 
> It should be doing that automatically for you, provided you give
> net/http a hostname rather than an IP address.  For me, this performs as
> expected (the host has several vhosts):
> 
> #!/usr/bin/env ruby -w
> require 'net/http'
> Net::HTTP.get_print('segment7.net', '/') # prints the page @ segment7.net
 
It looks like net/http is not specifying the host, or not doing
it correctly for this case.

irb(main):001:0> require 'net/http'
true
irb(main):002:0> Net::HTTP.get_print('www.kidteeth.com','/preload_timetest')
Net::HTTPBadResponse: wrong status line: <html>
        from /usr/local/lib/ruby/1.6/net/http.rb:1177:in `read_status'
        from /usr/local/lib/ruby/1.6/net/http.rb:1160:in `read_new'
        from /usr/local/lib/ruby/1.6/net/http.rb:676:in `request'
        from /usr/local/lib/ruby/1.6/net/http.rb:601:in `get'
        from /usr/local/lib/ruby/1.6/net/http.rb:459:in `get_print'
        from /usr/local/lib/ruby/1.6/net/http.rb:458:in `start'
        from /usr/local/lib/ruby/1.6/net/http.rb:458:in `get_print'
        from (irb):2
irb(main):003:0> Net::HTTP.get_print('www.kidteeth.com','/')
<html>
<body>
Please direct inquires to jim / freeze.org
</body>
</html>
nil


-- 
Jim Freeze
----------
Programming Ruby 
 def initialize; fun; end
A language with class