Sets the write timeout, in seconds, for self
to integer sec
; the initial value is 60.
Argument sec
must be a non-negative numeric value:
_uri = uri.dup _uri.path = '/posts' body = 'bar' * 200000 data = <<EOF {"title": "foo", "body": "#{body}", "userId": "1"} EOF headers = {'content-type': 'application/json'} http = Net::HTTP.new(hostname) http.write_timeout # => 60 http.post(_uri.path, data, headers) # => #<Net::HTTPCreated 201 Created readbody=true> http.write_timeout = 0 http.post(_uri.path, data, headers) # Raises Net::WriteTimeout.
Sends a GET request to the server; forms the response into a Net::HTTPResponse
object.
The request is based on the Net::HTTP::Get
object created from string path
and initial headers hash initheader
.
With no block given, returns the response object:
http = Net::HTTP.new(hostname) http.request_get('/todos') # => #<Net::HTTPOK 200 OK readbody=true>
With a block given, calls the block with the response object and returns the response object:
http.request_get('/todos') do |res| p res end # => #<Net::HTTPOK 200 OK readbody=true>
Output:
#<Net::HTTPOK 200 OK readbody=false>
Sends a HEAD request to the server; returns an instance of a subclass of Net::HTTPResponse
.
The request is based on the Net::HTTP::Head
object created from string path
and initial headers hash initheader
.
http = Net::HTTP.new(hostname) http.head('/todos/1') # => #<Net::HTTPOK 200 OK readbody=true>
Sends an HTTP request to the server; returns an instance of a subclass of Net::HTTPResponse
.
The request is based on the Net::HTTPRequest
object created from string path
, string data
, and initial headers hash header
. That object is an instance of the subclass of Net::HTTPRequest, that corresponds to the given uppercase string name
, which must be an HTTP request method or a WebDAV request method.
Examples:
http = Net::HTTP.new(hostname) http.send_request('GET', '/todos/1') # => #<Net::HTTPOK 200 OK readbody=true> http.send_request('POST', '/todos', 'xyzzy') # => #<Net::HTTPCreated 201 Created readbody=true>
Similar to inspect, but respects the current level of indentation given by the pretty print object.
def variable_call?: () -> bool
def variable_call?: () -> bool
def variable_call?: () -> bool
def variable_call?: () -> bool
def variable_call?: () -> bool
def variable_call?: () -> bool
def variable_call?: () -> bool
def variable_call?: () -> bool
def variable_call?: () -> bool
def static_keys?: () -> bool
Return the byte offset of the start of the line corresponding to the given byte offset.
The line number where this location starts.
The column number in bytes where this location starts from the start of the line.