Writes a number of random generated bytes (currently 1024) to filename which can be used to initialize the PRNG by calling ::load_random_file
in a later session.
Calls the block with each capitalized field name:
res = Net::HTTP.get_response(hostname, '/todos/1') res.each_capitalized_name do |key| p key if key.start_with?('C') end
Output:
"Content-Type" "Connection" "Cache-Control" "Cf-Cache-Status" "Cf-Ray"
The capitalization is system-dependent; see Case Mapping.
Returns an enumerator if no block is given.
Sets the value of field 'Content-Type'
; returns the new value; see Content-Type request header:
req = Net::HTTP::Get.new(uri) req.set_content_type('application/json') # => ["application/json"]
Net::HTTPHeader#content_type=
is an alias for Net::HTTPHeader#set_content_type
.
Yields to a block and preserves the previous set of objects being printed.
Creates a self-signed certificate with an issuer and subject from email
, a subject alternative name of email
and the given extensions
for the key
.
Asks for a password with a prompt
Run UDP/IP server loop on the given sockets.
The return value of Socket.udp_server_sockets
is appropriate for the argument.
It calls the block for each message received.
Add a list of paths to the $LOAD_PATH at the proper place.
Returns a URL-encoded string derived from the given string str
.
The returned string:
Preserves:
Characters '*'
, '.'
, '-'
, and '_'
.
Character in ranges 'a'..'z'
, 'A'..'Z'
, and '0'..'9'
.
Example:
URI.encode_www_form_component('*.-_azAZ09') # => "*.-_azAZ09"
Converts:
Character ' '
to character '+'
.
Any other character to “percent notation”; the percent notation for character c is '%%%X' % c.ord
.
Example:
URI.encode_www_form_component('Here are some punctuation characters: ,;?:') # => "Here+are+some+punctuation+characters%3A+%2C%3B%3F%3A"
Encoding:
If str
has encoding Encoding::ASCII_8BIT, argument enc
is ignored.
Otherwise str
is converted first to Encoding::UTF_8 (with suitable character replacements), and then to encoding enc
.
In either case, the returned string has forced encoding Encoding::US_ASCII.
Related: URI.encode_uri_component
(encodes ' '
as '%20'
).
Returns a string decoded from the given URL-encoded string str
.
The given string is first encoded as Encoding::ASCII-8BIT (using String#b
), then decoded (as below), and finally force-encoded to the given encoding enc
.
The returned string:
Preserves:
Characters '*'
, '.'
, '-'
, and '_'
.
Character in ranges 'a'..'z'
, 'A'..'Z'
, and '0'..'9'
.
Example:
URI.decode_www_form_component('*.-_azAZ09') # => "*.-_azAZ09"
Converts:
Character '+'
to character ' '
.
Each “percent notation” to an ASCII character.
Example:
URI.decode_www_form_component('Here+are+some+punctuation+characters%3A+%2C%3B%3F%3A') # => "Here are some punctuation characters: ,;?:"
Related: URI.decode_uri_component
(preserves '+'
).
Returns the string that is used to insert a space before the ‘:’ in JSON
objects.
Sets the string that is used to insert a space before the ‘:’ in JSON
objects.
This string is put at the end of a line that holds a JSON
array.
This string is put at the end of a line that holds a JSON
array.
Returns true, if circular data structures should be checked, otherwise returns false.
Returns true, if only ASCII characters should be generated. Otherwise returns false.