Ruby modules for HTTP clienting


#1

Hello,

I’m a Perl programmer in transition to Ruby. One of the biggest
problems with such a transition is the relative lack of modules in the
Ruby world. CPAN has made us Perl hackers lazy and over-confident :slight_smile:

I am doing some HTTP “clienting” work, and want to port it to Ruby. In
Perl I use the LWP::UserAgent, HTTP::Request and HTTP::Headers modules
for this purpose. I’m sure Ruby has an equivalent - could someone
please point me to the module I need ?
Also, LWP::UserAgent is smart enough to use SSL if the connection is
HTTPS and uses the Perl module Crypt::SSLeay for that. I hope this also
has a parallel in Ruby ?

Thanks in advance
Eli


#2

Also, LWP::UserAgent is smart enough to use SSL if the connection is
HTTPS and uses the Perl module Crypt::SSLeay for that. I hope this also
has a parallel in Ruby ?

It seems that what I was looking for is Net::HTTP

One question though - I want to use basic authentication (connecting to
an Atom feed with user/password). This works:

req.basic_auth(username, password)

However, this doesn’t, although I think it should:

encoded_userpass = Base64.encode64(user + ‘:’ + pass)
req.add_field(‘Authorization’, “Basic #{encoded_userpass}”)

What am I missing ?