# Request\_get VS request VS get

**URL:** <https://www.ruby-forum.com/t/request-get-vs-request-vs-get/79093>\
**Category:** Ruby\
**Created:** [December 12, 2006, 2:27am UTC](https://www.ruby-forum.com/t/request-get-vs-request-vs-get/79093 "2006-12-12T02:27:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mento\_ruby](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/a4c791/32.png) [@mento\_ruby](https://www.ruby-forum.com/u/mento_ruby)\
**Post date:** [December 12, 2006, 2:27am UTC](https://www.ruby-forum.com/t/request-get-vs-request-vs-get/79093/1 "2006-12-12T02:27:23Z")

</div>

wt’s the different of using “request\_get”, “request” and “get” provided  
in net/http library?  
Both of them can get the reponse.body

---

<div class="post-metadata">

**Author:** ![mento\_ruby](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/a4c791/32.png) [@mento\_ruby](https://www.ruby-forum.com/u/mento_ruby)\
**Post date:** [December 12, 2006, 4:32pm UTC](https://www.ruby-forum.com/t/request-get-vs-request-vs-get/79093/2 "2006-12-12T16:32:36Z")

</div>

Citát Mento R. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> 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/](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 V.

---

<div class="post-metadata">

**Author:** ![mento\_ruby](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/a4c791/32.png) [@mento\_ruby](https://www.ruby-forum.com/u/mento_ruby)\
**Post date:** [December 18, 2006, 2:51pm UTC](https://www.ruby-forum.com/t/request-get-vs-request-vs-get/79093/3 "2006-12-18T14:51:10Z")

</div>

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 = nil, dest = nil, &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.)
