Returns the array field value for the given key
, or nil
if there is no such field; see Fields:
res = Net::HTTP.get_response(hostname, '/todos/1') res.get_fields('Connection') # => ["keep-alive"] res.get_fields('Nosuch') # => nil
Calls the block with each key/value pair:
res = Net::HTTP.get_response(hostname, '/todos/1') res.each_header do |key, value| p [key, value] if key.start_with?('c') end
Output:
["content-type", "application/json; charset=utf-8"] ["connection", "keep-alive"] ["cache-control", "max-age=43200"] ["cf-cache-status", "HIT"] ["cf-ray", "771d17e9bc542cf5-ORD"]
Returns an enumerator if no block is given.
Net::HTTPHeader#each
is an alias for Net::HTTPHeader#each_header
.
Sets the value for field 'Range'
; see Range request header:
With argument length
:
req = Net::HTTP::Get.new(uri) req.set_range(100) # => 100 req['Range'] # => "bytes=0-99"
With arguments offset
and length
:
req.set_range(100, 100) # => 100...200 req['Range'] # => "bytes=100-199"
With argument range
:
req.set_range(100..199) # => 100..199 req['Range'] # => "bytes=100-199"
Net::HTTPHeader#range=
is an alias for Net::HTTPHeader#set_range
.
Returns a Range
object representing the value of field 'Content-Range'
, or nil
if no such field exists; see Content-Range response header:
res = Net::HTTP.get_response(hostname, '/todos/1') res['Content-Range'] # => nil res['Content-Range'] = 'bytes 0-499/1000' res['Content-Range'] # => "bytes 0-499/1000" res.content_range # => 0..499
Returns the integer representing length of the value of field 'Content-Range'
, or nil
if no such field exists; see Content-Range response header:
res = Net::HTTP.get_response(hostname, '/todos/1') res['Content-Range'] # => nil res['Content-Range'] = 'bytes 0-499/1000' res.range_length # => 500
Generates formatted random number from raw random bytes. See Random#rand
.
Creates an unsigned certificate for subject
and key
. The lifetime of the key is from the current time to age
which defaults to one year.
The extensions
restrict the key to the indicated uses.
Enumerates the trusted certificates via Gem::Security::TrustDir
.
Simple deprecation method that deprecates name
by wrapping it up in a dummy method. It warns on each call to the dummy method telling the user of repl
(unless repl
is :none) and the Rubygems version that it is planned to go away.
Simple deprecation method that deprecates name
by wrapping it up in a dummy method. It warns on each call to the dummy method telling the user of repl
(unless repl
is :none) and the Rubygems version that it is planned to go away.
Guts of original execute
Displays a warning statement
to the warning output location. Asks a question
if given.