Problems Using Net::HTTP

Hope someone can follow this…

I have an action in a controller which attempts to use
Net::HTTP.get_response() to get pages over http so it can write them to
disk.

If I do this:
response =
Net::HTTP.get_response(URI.parse(“http://localhost:3000/index.html”))
It fails the error shown at the bottom of this post

But if I replace localhost with the name of our staging server (which is
on a different machine) it succeeds:
response =
Net::HTTP.get_response(URI.parse(“http://staging:3000/index.html”))

Both http://localhost:3000/index.html and
http://stageing:3000/index.html pull up identical pages when invoked in
a browser.

Should I be able to use
Net::HTTP.get_response(URI.parse(“http://localhost:3000/index.html”)) in
an action which itself is being invoked on localhost?

Incidentally if I try to run
response =
Net::HTTP.get_response(URI.parse(“http://staging:3000/index.html”)) on
the staging server itself, I run into the same error.


Here’s The Error

[2007-01-31 14:11:32] ERROR Errno::EINVAL: Invalid argument
c:/ruby/lib/ruby/1.8/webrick/httpresponse.rb:324:in write' c:/ruby/lib/ruby/1.8/webrick/httpresponse.rb:324:in_write_data’
c:/ruby/lib/ruby/1.8/webrick/httpresponse.rb:296:in
send_body_string' c:/ruby/lib/ruby/1.8/webrick/httpresponse.rb:187:insend_body’
c:/ruby/lib/ruby/1.8/webrick/httpresponse.rb:104:in
send_response' c:/ruby/lib/ruby/1.8/webrick/httpserver.rb:79:inrun’
c:/ruby/lib/ruby/1.8/webrick/server.rb:173:in start_thread' c:/ruby/lib/ruby/1.8/webrick/server.rb:162:instart_thread’
c:/ruby/lib/ruby/1.8/webrick/server.rb:95:in start' c:/ruby/lib/ruby/1.8/webrick/server.rb:92:instart’
c:/ruby/lib/ruby/1.8/webrick/server.rb:23:in start' c:/ruby/lib/ruby/1.8/webrick/server.rb:82:instart’
c:/ruby/lib/ruby/gems/1.8/gems/rails-1.1.4/lib/webrick_server.rb:67:in
dispatch' c:/ruby/lib/ruby/gems/1.8/gems/rails-1.1.4/lib/commands/servers/webrick.rb:59 c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:inrequire’
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:147:in
require' c:/ruby/lib/ruby/gems/1.8/gems/rails-1.1.4/lib/commands/server.rb:30 c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:inrequire’
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:147:in
`require’
script/server:3

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs