Gmail atom feed

I'm trying to use basic auth to retrieve my Gmail atom feed but I keep on
getting "Connection reset by peer".

Here's the code:

$URL_FEED = 'https://mail.google.com/mail/feed/atom'

def retrieve
        puts "Retrieving mail count..."
        @url = URI.parse($URL_FEED)
        h = Net::HTTP.new(@url.host,@url.port)
        begin
            unpw = [@email,@password]
            unpw = @unpw.join(':')
            z=[unpw].pack("m")
            @unpwd={'Authorization' => 'Basic ' + z }
            puts @unpwd
            resp = h.get(@url.path,@unpwd)
            @headers = ""
            resp.each {|key,val| @headers.concat("#{key}: #{val}\n")}
            puts @response.body
        rescue Net::ProtoFatalError => detail
            head = detail.data
            head.each {|key,val| puts "#{key} #{val}"}
        end
end

This is HTTPS. See /usr/lib/ruby/1.8/net/https.rb (or the equivalent on your
system) for an example of how to use HTTPS URLs.

···

On Wed, May 23, 2007 at 12:01:14AM +0900, Fred Phillips wrote:

I'm trying to use basic auth to retrieve my Gmail atom feed but I keep on
getting "Connection reset by peer".

Here's the code:

$URL_FEED = 'https://mail.google.com/mail/feed/atom'

def retrieve
       puts "Retrieving mail count..."
       @url = URI.parse($URL_FEED)
       h = Net::HTTP.new(@url.host,@url.port)
       begin
           unpw = [@email,@password]
           unpw = @unpw.join(':')
           z=[unpw].pack("m")
           @unpwd={'Authorization' => 'Basic ' + z }
           puts @unpwd
           resp = h.get(@url.path,@unpwd)
           @headers = ""
           resp.each {|key,val| @headers.concat("#{key}: #{val}\n")}
           puts @response.body
       rescue Net::ProtoFatalError => detail
           head = detail.data
           head.each {|key,val| puts "#{key} #{val}"}
       end
end

I only have:
ftp.rb http.rb imap.rb pop.rb protocol.rb smtp.rb telnet.rb

in my net/ directory

···

On 22/05/07, Brian Candler <B.Candler@pobox.com> wrote:

On Wed, May 23, 2007 at 12:01:14AM +0900, Fred Phillips wrote:
> I'm trying to use basic auth to retrieve my Gmail atom feed but I keep
on
> getting "Connection reset by peer".
>
> Here's the code:
>
> $URL_FEED = 'https://mail.google.com/mail/feed/atom&#39;
>
> def retrieve
> puts "Retrieving mail count..."
> @url = URI.parse($URL_FEED)
> h = Net::HTTP.new(@url.host,@url.port)
> begin
> unpw = [@email,@password]
> unpw = @unpw.join(':')
> z=[unpw].pack("m")
> @unpwd={'Authorization' => 'Basic ' + z }
> puts @unpwd
> resp = h.get(@url.path,@unpwd)
> @headers = ""
> resp.each {|key,val| @headers.concat("#{key}: #{val}\n")}
> puts @response.body
> rescue Net::ProtoFatalError => detail
> head = detail.data
> head.each {|key,val| puts "#{key} #{val}"}
> end
> end

This is HTTPS. See /usr/lib/ruby/1.8/net/https.rb (or the equivalent on
your
system) for an example of how to use HTTPS URLs.

So, let me guess - you're using Ubuntu or Debian, right? If so you'll need

# apt-get install libopenssl-ruby1.8

If not, then please describe your system.

(Aside: This really belongs in a FAQ.
  1. Always state exactly what system you're running under.
  2. If running Debian/Ubuntu, Ruby is broken into shrapnel packages)

···

On Wed, May 23, 2007 at 12:39:52AM +0900, Fred Phillips wrote:

I only have:
ftp.rb http.rb imap.rb pop.rb protocol.rb smtp.rb telnet.rb

in my net/ directory

Thanks, it's working perfectly now.

···

On 22/05/07, Brian Candler <B.Candler@pobox.com> wrote:

On Wed, May 23, 2007 at 12:39:52AM +0900, Fred Phillips wrote:
> I only have:
> ftp.rb http.rb imap.rb pop.rb protocol.rb smtp.rb telnet.rb
>
> in my net/ directory

So, let me guess - you're using Ubuntu or Debian, right? If so you'll need

# apt-get install libopenssl-ruby1.8

If not, then please describe your system.

(Aside: This really belongs in a FAQ.
  1. Always state exactly what system you're running under.
  2. If running Debian/Ubuntu, Ruby is broken into shrapnel packages)

And if you *are* using Debian Etch (4.0), you can use this script:

http://pastie.caboo.se/63595

That I put together from:

···

On May 22, 2007, at 1:24 PM, Brian Candler wrote:

On Wed, May 23, 2007 at 12:39:52AM +0900, Fred Phillips wrote:

I only have:
ftp.rb http.rb imap.rb pop.rb protocol.rb smtp.rb telnet.rb

in my net/ directory

So, let me guess - you're using Ubuntu or Debian, right? If so you'll need

# apt-get install libopenssl-ruby1.8

If not, then please describe your system.

(Aside: This really belongs in a FAQ.
  1. Always state exactly what system you're running under.
  2. If running Debian/Ubuntu, Ruby is broken into shrapnel packages)

#===============================================================================
# Based on the Rails stack script from RimuHosting
#-------------------------------------------------------------------------------
# Written by Peter over at RimuHosting.com (we provide Linux VPS hosting services)
# Last major update: 2006-06-18
# for a bit of a blurb about this script see
# http://bliki.rimuhosting.com/space/knowledgebase/linux/miscapplications/ruby+on+rails
#
# the latest version of this script is typically found at http://downloads.rimuhosting.com/miscproj/rails.sh
#===============================================================================
# and the blog post by Mike Mondragon:
# "compiling ruby 1.8.5 w/ openssl on Debian (Etch/testing) and FreeBSD in $HOME"
#-------------------------------------------------------------------------------
#compiling ruby 1.8.5 w/ openssl on Debian (Etch/testing) and FreeBSD in $HOME | Plasticx Blog
#===============================================================================

If you don't have root access on your system, then take a look at the script and make the appropriate modifications. Mike Mondragon's article specifically addresses building in a local directory where you don't have the permission to put things in the "global" place in the filesystem.

-Rob

Rob Biedenharn http://agileconsultingllc.com
Rob@AgileConsultingLLC.com