D
Dan Tenenbaum
I had some code that used to work and now all of a sudden it stopped
working. Here is the minimal code to illustrate the problem:
#!/usr/bin/ruby
require 'net/http'
require 'uri'
parms = {:client=>"safari", :rls=>"en", :q => "myquery",
:ie => "UTF-8", e => "UTF-8"}
url = "http://www.google.com/search"
res = Net::HTTP.post_form(URI.parse(url), parms)
print res.body
print
The code fails with this error:
/foo.rb:8: undefined method `post_form' for Net::HTTP:Class
(NoMethodError)
However, my code is almost identical to the example at:
http://www.ruby-doc.org/stdlib/libdoc/net/http/rdoc/classes/Net/HTTP.html#M001204
...which presumably should work.
This is on a mac. I tried it on a windows box and it failed with the
same error. I tried it on a linux box and it worked (the request format
isn't quite right, but *something* came back from the server and was
printed out, so for the purposes of this post, it "works").
Anyone have any ideas as to why? Apparently I have the Net::HTTP class
but it doesn't have the post_form method in it....anymore....
Hope someone can help.
working. Here is the minimal code to illustrate the problem:
#!/usr/bin/ruby
require 'net/http'
require 'uri'
parms = {:client=>"safari", :rls=>"en", :q => "myquery",
:ie => "UTF-8", e => "UTF-8"}
url = "http://www.google.com/search"
res = Net::HTTP.post_form(URI.parse(url), parms)
print res.body
The code fails with this error:
/foo.rb:8: undefined method `post_form' for Net::HTTP:Class
(NoMethodError)
However, my code is almost identical to the example at:
http://www.ruby-doc.org/stdlib/libdoc/net/http/rdoc/classes/Net/HTTP.html#M001204
...which presumably should work.
This is on a mac. I tried it on a windows box and it failed with the
same error. I tried it on a linux box and it worked (the request format
isn't quite right, but *something* came back from the server and was
printed out, so for the purposes of this post, it "works").
Anyone have any ideas as to why? Apparently I have the Net::HTTP class
but it doesn't have the post_form method in it....anymore....
Hope someone can help.