I'm having trouble making basic authentication work.
I have searched the archives for how to do this and came up with this
example from message 10984.

Here's the code:
[donald@localhost linksys]$ cat link.rb
#!/usr/local/bin/ruby
 
require 'net/http'
require 'base64'
 
h = Net::HTTP.new('192.168.1.1',80)
 
enc = "Basic" + encode64( "donald:secret" )
 
resp, data = h.get( '/index.html', 'Authorization' => enc );
 
puts "Code = #{resp.code}"
puts "Message = #{resp.message}"
 
resp.each { |key, val| printf "%s = %s\n", key, val } 

Here's the output:

[donald@localhost linksys]$ ./link.rb
Code = 401
Message = Authorization Required
content-type = image/gif
www-authenticate = Basic realm="Linksys BEFSR41/BEFSR11/BEFSRU31"
expires = Thu, 13 Dec 1969 10:29:00 GMT
pragma = no-cache 


Am I doing something wrong?  I see that there is a HTTPHeader
class that has a basic_auth method, but I don't see how I should
use it.

Any help would be apreciated

Thanks!

donald