On Monday, September 8, 2003, at 09:00  PM, Shashank Date wrote:
> "Harry Ohlsen" <harryo / qiqsolutions.com> wrote in message
> news:3F5D1667.9080200 / qiqsolutions.com...
>> Ila'n Terrell wrote:
>>
>>> /usr/lib/ruby/1.6/net/protocol.rb:221:in `error!': 302 "Moved
>>
>>> I am pretty new to ruby and I don't have the slightest clue what 
>>> "Moved
>>> Temporarily" means. I have tried this on multiple platforms and get 
>>> the
>>> same error. Any ideas?
>>
>> That's an HTTP error code; I don't believe it has anything to do
>> with the Ruby code, other than that it's passing on what the web 
>> server
> sent it.

In this case, the page is detecting the language that's appropriate for 
the visitor and redirecting them to the English or the Japanese page:

% telnet www.ruby-lang.org 80
Trying 210.251.121.214...
Connected to www.ruby-lang.org.
Escape character is '^]'.
GET / HTTP/1.1
Host: www.ruby-lang.org

HTTP/1.1 301 Moved Permanently
Date: Tue, 09 Sep 2003 01:56:02 GMT
Server: Apache/1.3.26 (Unix) Debian GNU/Linux mod_ruby/0.9.7 Ruby/1.6.7
Location: http://www.ruby-lang.org/en/index.html
Transfer-Encoding: chunked
Content-Type: text/html; charset=iso-8859-1

f2
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<HTML><HEAD>
<TITLE>301 Moved Permanently</TITLE>
</HEAD><BODY>
<H1>Moved Permanently</H1>
The document has moved <A 
HREF="http://www.ruby-lang.org/en/index.html">here</A>.<P>
</BODY></HTML>


> Yes, but if you run it using ruby 1.8.0 it does not throw any error,
> just displays the HTTP error (along with some warnings).
> On Windows XP Pro (using /\ndy's one-click installer)

Between 1.6.X and 1.8 the Net::HTTP module has changed, you should use:

resp = h.get('/', nil )

rather than:

resp, data = h.get('/', nil )

The other difference is that in 1.8, a 300 series error (a redirect) is 
no longer an exception.  Instead, you have to examine the return codes 
and check to see if it was a redirect, using something like:

def getPage(url, header_hash, retry_count)

   raise("Too many redirects") if 10 < retry_count

   case response
   when Net::HTTPSuccess
     response
   when Net::HTTPRedirection
     getPage(url.merge(URI.parse(response['location'])),
             header_hash,
             retry_count + 1)
   else
     response.error!
   end
end

Ben