From: Niklas Frykholm Date: 2002-02-18T09:46:19+09:00 Subject: Re: net/http or webfetcher with pasworded urls [Ron Jeffries]: > Is there a way to use webfetcher, or at least net/http, with a > passworded URL? No support for this in webfetcher yet, I'm afraid. Though it doesn't seem that hard to add. > What am I missing, and where should I have read about it? You cannot use a passworded URL directly with Net::HTTP, since Net::HTTP doesn't really parse URLs. (Upcoming URI class will, I suppose.) This is from the net/http.rb file in the standard library (1.7): === Basic Authentication require 'net/http' Net::HTTP.start( 'auth.some.domain' ) {|http| response , = http.get( '/need-auth.cgi', 'Authentication' => ["#{account}:#{password}"].pack('m').strip ) print response.body } In version 1.2 (Ruby 1.7 or later), you can write like this: require 'net/http' req = Net::HTTP::Get.new('/need-auth.cgi') req.basic_auth 'account', 'password' Net::HTTP.start( 'auth.some.domain' ) {|http| response = http.request(req) print response.body } // Niklas