Unmarshall a marshalled DRbObject
.
If the referenced object is located within the local server, then the object itself is returned. Otherwise, a new DRbObject
is created to act as a stub for the remote referenced object.
Reads the next expression from this printer.
See IO#gets
for more information.
Returns true
; retained for compatibility.
Sends a GET request and returns the HTTP response body as a string.
With string arguments hostname
and path
:
hostname = 'jsonplaceholder.typicode.com' path = '/todos/1' puts Net::HTTP.get(hostname, path)
Output:
{ "userId": 1, "id": 1, "title": "delectus aut autem", "completed": false }
With URI
object uri
and optional hash argument headers
:
uri = URI('https://jsonplaceholder.typicode.com/todos/1') headers = {'Content-type' => 'application/json; charset=UTF-8'} Net::HTTP.get(uri, headers)
Related:
Net::HTTP::Get
: request class for HTTP method GET
.
Net::HTTP#get
: convenience method for HTTP method GET
.
Retrieves data from path
on the connected-to host which may be an absolute path String
or a URI
to extract the path from.
initheader
must be a Hash
like { ‘Accept’ => ‘/’, … }, and it defaults to an empty hash. If initheader
doesn’t have the key ‘accept-encoding’, then a value of “gzip;q=1.0,deflate;q=0.6,identity;q=0.3” is used, so that gzip compression is used in preference to deflate compression, which is used in preference to no compression. Ruby doesn’t have libraries to support the compress (Lempel-Ziv) compression, so that is not supported. The intent of this is to reduce bandwidth by default. If this routine sets up compression, then it does the decompression also, removing the header as well to prevent confusion. Otherwise it leaves the body as it found it.
This method returns a Net::HTTPResponse
object.
If called with a block, yields each fragment of the entity body in turn as a string as it is read from the socket. Note that in this case, the returned response object will not contain a (meaningful) body.
dest
argument is obsolete. It still works but you must not use it.
This method never raises an exception.
response = http.get('/index.html') # using block File.open('result.txt', 'w') {|f| http.get('/~foo/') do |str| f.write str end }
Sends a LOCK request to the path
and gets a response, as an HTTPResponse
object.
Sends a UNLOCK request to the path
and gets a response, as an HTTPResponse
object.
Pushes back erred argument(s) to argv
.
Default stringizing method to emit standard error message.