Ruby doesn't work correctly

P

Patrick

Hi,

Im a beginner in Ruby, but with skills in other programming languages.

I tried to execute the following code:

require 'net/http'
require 'uri'

#1: Simple POST
res =
Net::HTTP.post_form(URI.parse('http://www.example.com/search.cgi'),
{'q'=>'ruby', 'max'=>'50'})
puts res.body

I got the code from http://www.ruby-doc.org/stdlib/ -> net/http. Of
course, I replaced the Site ("www.example.com...") with my site
(because i want to send informations to a php-programm).

But the console does the following output:

mypath/ruby/lib/ruby/1.8/net/protocol.rb:175:in `write': Invalid
argument (Errno::EI
NVAL)
from mypath/ruby/lib/ruby/1.8/net/protocol.rb:175:in `write0'
from mypath/ruby/lib/ruby/1.8/net/protocol.rb:151:in `write'
from mypath/ruby/lib/ruby/1.8/net/protocol.rb:166:in `writing'
from mypath/ruby/lib/ruby/1.8/net/protocol.rb:150:in `write'
from mypath/ruby/lib/ruby/1.8/net/http.rb:1542:in
`write_header'
from mypath/ruby/lib/ruby/1.8/net/http.rb:1513:in
`send_request_with_body'
from mypath/ruby/lib/ruby/1.8/net/http.rb:1496:in `exec'
from mypath/ruby/lib/ruby/1.8/net/http.rb:1044:in `request'
from mypath/ruby/lib/ruby/1.8/net/http.rb:405:in `post_form'
from mypath/ruby/lib/ruby/1.8/net/http.rb:545:in `start'
from mypath/ruby/lib/ruby/1.8/net/http.rb:404:in `post_form'
from mypath/php.rb:5

Line 5 is: res =
Net::HTTP.post_form(URI.parse('http://www.example.com/search.cgi'),
{'q'=>'ruby', 'max'=>'50'})

I thought my ruby is maybe damaged, so i deleted it, and installed it
new. But i get always the same error.

I hope anyone would be so kind and can help me.

Thank you,

Patrick
 
J

Jay

Patrick,

I'm even more of a beginner in Ruby than you are, but I'm wondering if
you cant put a breakpoint in the ruby code and debug it. I'm using
ActiveState Komodo, which allows for Ruby debugging, and the file you
referenced, "protocol.rb", is included when you install ruby.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top