From: Brian Candler Date: 2007-05-23T00:26:36+09:00 Subject: Re: Gmail atom feed 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 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.