net/http question

F

Fabian Boucsein

Hello Ruby users,

i got the following question for you:

The following function:

def ret
return [0, 1]
end

returns an array with two elements.
If i use this function like this:

ar = ret

the variable ar contains the array.
If i use the get method from the
net/http module like this:

h = Net::HTTP.get("/index.html", nil)

the h variable just contains the Request
object and not like documented the array.
Which is given back when using irb. I can
see it there.
Is it possible to store the array given back
by the net/http get method?
 
M

Minero Aoki

Hi,

In mail "net/http question"
Fabian Boucsein said:
If i use the get method from the
net/http module like this:

h = Net::HTTP.get("/index.html", nil)

the h variable just contains the Request
object and not like documented the array.

Net::HTTP#get returns a Net::HTTP::Response object from Ruby 1.8.
If you want Ruby 1.6 compatible behavior, use:

require 'net/http'
Net::HTTP.version_1_1


Best Regards,
Minero Aoki
 

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

Forum statistics

Threads
474,169
Messages
2,570,920
Members
47,463
Latest member
FinleyMoye

Latest Threads

Top