--------------080205060805000601030308
Content-Type: text/plain; charset=ISO-8859-2; format=flowed
Content-Transfer-Encoding: 8bit
There are really two "get" methods in Net::HTTP. But one is Class
method Net::HTTP::get, and the other is Instance method
Net::HTTP.get(Net::HTTP#get). So it is easy to differentiate these two
get methods. Then our goal should be to differentiate the following 3
methods.
1) Net::HTTP#request_get
2) Net::HTTP#request
3) Net::HTTP#get
Net::HTTP#request_get means to send a GET request to the path
and get a response, as an HTTPResponse object. However Net::HTTP#request
means to send an HTTPRequest object REQUEST to the HTTP server. I.e.,
The HTTPRequest object of Net::HTTP#request might be either get/head
request or post/put request. This is the difference between it and
Net::HTTP#request_get.
Regarding Net::HTTP#get: In version 1.1 (ruby 1.6), it returns a
pair of objects, a Net::HTTPResponse object and the entity body string;
In version 1.2 (ruby 1.8), it returns a Net::HTTPResponse object. From
ruby 1.8, I think, Net::HTTP#get has very little difference with
Net::HTTP#request_get. The former method has a param named dest, which
Net::HTTP#request_get doesn't have, as follows:
get(path, initheader il, dest il, &block)
Moreover, there's been a method Net::HTTP#get2 that is
identical to Net::HTTP#request_get.
Regards,
Shiwei
(The views expressed are my own and not necessarily those of Oracle and
its affiliates.)
david / vallner.net wrote:
>CitáÕ Mento Ruby <mento_ruby / hotmail.com>:
>
>
>
>>wt's the different of using "request_get", "request" and "get" provided
>>in net/http library?
>>Both of them can get the reponse.body
>>
>>--
>>Posted via http://www.ruby-forum.com/.
>>
>>
>>
>>
>
>
>Which get? I see both Net::HTTP::get, and Net::HTTP#get in the standard
>documentation.
>
>Also, it seems for #request you provide the request header yourself, method,
>HTTP version and all, for #request_get you only provide the URL.
>
>David Vallner
>
>
>
>
--------------080205060805000601030308--