Noel Mc grath wrote:
> New to ruby and trying to do a HTTP POST. From looking at documentation
> it states
> "In version 1.1 (ruby 1.6), this method returns a pair of objects, a
> Net::HTTPResponse object and an entity body string. In version 1.2 (ruby
> 1.8), this method returns a Net::HTTPResponse object."
> 
> What does it mean by version 1.1 and 1.2?

Of the Net::HTTP API. Look in the source; depending on your system this 
may be somewhere like /usr/lib/ruby/1.8/net/http.rb

  # == Switching Net::HTTP versions
  #
  # You can use net/http.rb 1.1 features (bundled with Ruby 1.6)
  # by calling HTTP.version_1_1. Calling Net::HTTP.version_1_2
  # allows you to use 1.2 features again.
  #
  #     # example
  #     Net::HTTP.start {|http1| ...(http1 has 1.2 features)... }
  #
  #     Net::HTTP.version_1_1
  #     Net::HTTP.start {|http2| ...(http2 has 1.1 features)... }
  #
  #     Net::HTTP.version_1_2
  #     Net::HTTP.start {|http3| ...(http3 has 1.2 features)... }
  #
  # This function is NOT thread-safe.

This was for backwards-compatibility - something which was taken 
seriously between ruby 1.6 and 1.8...

> I am using ruby version 1.9.2 and the method is returning a pair of
> objects:
> Net::HTTPResponse
> string

Odd. Here I get:

ruby-1.9.2-p0 > require 'net/http'
 => true
ruby-1.9.2-p0 > Net::HTTP.version_1_1?
 => false
ruby-1.9.2-p0 > Net::HTTP.version_1_2?
 => true
ruby-1.9.2-p0 > RUBY_DESCRIPTION
 => "ruby 1.9.2p0 (2010-08-18 revision 29036) [i686-linux]"
ruby-1.9.2-p0 > res = nil; Net::HTTP.start("www.google.com",80) { |http| 
res = http.post "/", "q=ruby" }
 => #<Net::HTTPMethodNotAllowed 405 Method Not Allowed readbody=true>
ruby-1.9.2-p0 > res
 => #<Net::HTTPMethodNotAllowed 405 Method Not Allowed readbody=true>

So although this particular operation fails, you can see I'm only 
getting a single object (response), not an array of two objects.

Is it possible that you are loading some other library which is 
switching Net::HTTP into its old (1.1) mode?
-- 
Posted via http://www.ruby-forum.com/.