Sets the value of field 'Content-Length'
to the given numeric; see Content-Length response header:
_uri = uri.dup hostname = _uri.hostname # => "jsonplaceholder.typicode.com" _uri.path = '/posts' # => "/posts" req = Net::HTTP::Post.new(_uri) # => #<Net::HTTP::Post POST> req.body = '{"title": "foo","body": "bar","userId": 1}' req.content_length = req.body.size # => 42 req.content_type = 'application/json' res = Net::HTTP.start(hostname) do |http| http.request(req) end # => #<Net::HTTPCreated 201 Created readbody=true>
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
Sets header 'Authorization'
using the given account
and password
strings:
req.basic_auth('my_account', 'my_password') req['Authorization'] # => "Basic bXlfYWNjb3VudDpteV9wYXNzd29yZA=="
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.
Creates a new digest instance using the specified algorithm
. The default is SHA256.
Creates a new key pair of the specified algorithm
. RSA, DSA, and EC are supported.
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.
If response
is an HTTP Success (2XX) response, yields the response if a block was given or shows the response body to the user.
If the response was not successful, shows an error to the user including the error_prefix
and the response body. If the response was a permanent redirect, shows an error to the user including the redirect location.
Wraps text
to wrap
characters and optionally indents by indent
characters
Message to promote available RubyGems update with related gem update command.
Enumerates the parents of directory
.
Discard statistics collected for --yjit-stats
.
Format and print out counters as a String
. This returns a non-empty content only when --yjit-stats
is enabled.
alias foo bar ^^^^^^^^^^^^^