Any suggestions? I did try the other clip of code posted here, but got
more errors than this one. =/ I’m reading up on that link posted in the
2nd post to see if I can figure any of this out.
Nice. I tested your code and it works for me. But my reading of the
docs says that it shouldn’t work: new() doesn’t open a connection, and
get(), “Gets data from path on the connected-to host.” The docs seem
to want you to do something like:
It says that Net::HTTP#get will:
“Send a GET request to the target and return the response as a string”
and Net::HTTP#get_response will:
“Send a GET request to the target and return the response as a
Net::HTTPResponse object”
The #new in this case is optional because both methods are class methods
or instance methods? Someone might be able to clarify this a part a
little more. But the examples at that doc url don’t even use
New::HTTP#new.
Nice. I tested your code and it works for me. But my reading of the
docs says that it shouldn’t work: new() doesn’t open a connection, and
get(), “Gets data from path on the connected-to host.” The docs seem
to want you to do something like:
Nice. I tested your code and it works for me. But my reading of the
docs says that it shouldn’t work: new() doesn’t open a connection, and
get(), “Gets data from path on the connected-to host.” The docs seem
to want you to do something like:
new() creates an instance, which is being used to call get(), so the
version of get() being called is the instance method. Yet, the docs say
the get() instance method “Gets data from path on the connected-to
host”. What connected to host? According to the docs on new() it says,
“This method does not open the TCP connection.”
In addition, the get() version in that code cannot be the class method
version because the class method version returns a String and Strings do
not have a body() method, which is the next method call.
Someone might be able to clarify this a part a
little more. But the examples at that doc url don’t even use
New::HTTP#new.
new() creates an instance, which is being used to call get(), so the
version of get() being called is the instance method. Yet, the docs say
the get() instance method “Gets data from path on the connected-to
host”. What connected to host? According to the docs on new() it says,
“This method does not open the TCP connection.”
As far as I can tell, you should have to call start() on a Net::HTTP
instance in order to open a connection, e.g.: