[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

"Moved Temporarily"?

Ilán Terrell

9/8/2003 11:35:00 PM

When trying to run the following code from "Programming Ruby" I get an
error message stating
Fetching: www.rubycentral.com
Fetching: www.awl.com
Fetching: www.pragmaticprogrammer.com
Got www.rubycentral.com: OK
/usr/lib/ruby/1.6/net/protocol.rb:221:in `error!': 302 "Moved
Temporarily" (Net::ProtoRetriableError)
from /Users/ilanterrell/Documents/ RubyScripts/threads.rb:20:in
`join'
from /Users/ilanterrell/Documents/ RubyScripts/threads.rb:20
from /Users/ilanterrell/Documents/ RubyScripts/threads.rb:20:in
`each'
from /Users/ilanterrell/Documents/ RubyScripts/threads.rb:20
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?

#!/usr/bin/ruby
require 'net/http'

pages = %w( www.rubycentral.com
www.awl.com
www.pragmaticprogrammer.com
)
threads = []

for page in pages
threads << Thread.new(page) { |myPage|

h = Net::HTTP.new(myPage, 80)
puts "Fetching: #{myPage}"
resp, data = h.get('/', nil )
puts "Got #{myPage}: #{resp.message}"
}
end

threads.each { |aThread| aThread.join }

???? ???

3 Answers

Harry Ohlsen

9/8/2003 11:54:00 PM

0

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.

I would imagine what the error means is that the web page has been moved to some other location.

Cheers,

Harry O.



Aria Stewart

9/9/2003 12:25:00 AM

0

> 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.

Exactly right.
>
> I would imagine what the error means is that the web page has been
> moved to some other location.

It does. The headers that are returned in that request should include
one labelled "Location:", which is the new URL.

"302" means that the old URL should still be used, and is /not/
obsolete. If it were "301", you should change the URL and use the new
one, always.

Ari

Shashank Date

9/9/2003 12:40:00 AM

0


"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.

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)
----------------------------------------------------------------------------
C:\atest>type tst_http2.rb
#!/usr/bin/ruby
require ''net/http''

pages = %w( www.rubycentral.com
www.awl.com
www.pragmaticprogrammer.com
)
threads = []

for page in pages
threads << Thread.new(page) { |myPage|

h = Net::HTTP.new(myPage, 80)
puts "Fetching: #{myPage}"
resp, data = h.get(''/'', nil )
puts "Got #{myPage}: #{resp.message}"
}
end

threads.each { |aThread| aThread.join }

C:\atest>ruby -v tst_http2.rb
ruby 1.8.0 (2003-08-04) [i386-mswin32]
Fetching: www.rubycentral.com
Fetching: www.awl.com
Fetching: www.pragmaticprogrammer.com
net/http: warning: old style assignment found at tst_http2.rb:15
Got www.rubycentral.com: OK
net/http: warning: old style assignment found at tst_http2.rb:15
Got www.awl.com: Moved Temporarily
net/http: warning: old style assignment found at tst_http2.rb:15
Got www.pragmaticprogrammer.com: OK

C:\atest>