RestClient send method?

Hey all,

I see this line of code:

RestClient.send(verb, url, parameters)

Basically there’s two rails application that communicate with each
other. RestClient is a rails gem. Here we send the get http verb and a
url string comprising of the other application base url and append a
query string to it consisting of the new user email that is being
created. So if the arguments are these:

RestClient.send(:get,
www.otherapp.com/users/[email protected])

What exactly would RestClient get back as the response? I don’t mean
this specific case, but I mean what is supposed to be sent back to
client in general. Or even if it is the ruby send
method, what exactly is RestClient doing with these two parameters?

I looked in documentation:

and it didn’t give a clear answer. The documentation shows you how to
use it but it doesn’t explain why you would want to do something about.
Before I understand how to use it, I think I need to know why. It
appears to have nothing to do with cookies and that’s typically how you
can maintain a browser state from one app to the next.

Thanks for response.

On 6 May 2011, at 01:53, John M. [email protected] wrote:

created. So if the arguments are these:
I looked in documentation:

https://github.com/archiloque/rest-client

and it didn’t give a clear answer.

Which bit of

for results code between 200 and 207 a RestClient::Response will be
returned
for results code 301, 302 or 307 the redirection will be followed if the
request is a get or a head
for result code 303 the redirection will be followed and the request
transformed into a get
for other cases a RestClient::Exception holding the Response will be
raised, a specific exception class will be thrown for known error codes
Is not clear?

The documentation shows you how to
use it but it doesn’t explain why you would want to do something about.
Before I understand how to use it, I think I need to know why. It
appears to have nothing to do with cookies and that’s typically how you
can maintain a browser state from one app to the next.

It sends http requests. Why you would want to send http requests is up
to you

Fred

John,

RestClient is a thin wrapper fot Net::HTTP standard library

http://www.ruby-doc.org/stdlib/libdoc/net/http/rdoc/index.html

And it assumes that you already know how to use it and why; it just
simplifies (if you know how to use Net::HTTP) usage of Net:HTTP.

My advice is instead of getting stuck at RestClient documentation look
at documentation for Net::HTTP and only then jump directly to RestClient
source code, which is pretty simple and self explanatory; you don’t
event have to go to source code in your local gem, just use github:

https://github.com/archiloque/rest-client/tree/master/lib/restclient

Hope it helps.


http://blog.eugen.co

thanks for responses