That did it. I had to see that there was a space between BASIC and its
closing quote, but that seems to have me on the page!

Thanks Rich, and everyone!

Now on to the /next/ problem ...

Ron

On Mon, 18 Feb 2002 17:30:29 GMT, "Rich Kilmer" <rich / infoether.com>
wrote:

>> >		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
>> >		}
>>
>> Hmmm, when I do this it still gives the 401 error.  Got me pretty
>> confused, I must say ...
>
>HTTP authentication works through the Authorization header (which is what
>the above code does...but the format is wrong???).
>
>According to my HTTP Pocket Reference, the format of the Authorization
>header in an HTTP request is:
>
>GET /protectedpage.html HTTP/1.0
>Authorization: BASIC s2dfVDdadfDfd==
>
>Where that big nasty string after BASIC is the base64 encoded value of
>'username:password'.  In the above example the code...
>
>["#{account}:#{password}"].pack('m').strip
>
>..gives you a base64 encoding.  I think that the problem with the above
>code is they left out the word BASIC (and again, had the wrong header)
>
>Net::HTTP.start( 'auth.some.domain' ) {|http|
> response , = http.get( '/whatever.html',
>	'Authorization' =>
>      "BASIC "+["#{account}:#{password}"].pack('m').strip )
>	print response.body
>}
>
>Give that a whirl.


Ronald E Jeffries
http://www.XProgramming.com
http://www.objectmentor.com
I'm giving the best advice I have. You get to decide whether it's true for you.