OpenSSL
IO
buffering mix-in module.
This module allows an OpenSSL::SSL::SSLSocket
to behave like an IO
.
You typically won’t use this module directly, you can see it implemented in OpenSSL::SSL::SSLSocket
.
The GC
profiler provides access to information on GC
runs including time, length and object space size.
Example:
GC::Profiler.enable require 'rdoc/rdoc' GC::Profiler.report GC::Profiler.disable
See also GC.count
, GC.malloc_allocated_size
and GC.malloc_allocations
Mixin module that provides the following:
Access to the CGI
environment variables as methods. See documentation to the CGI
class for a list of these variables. The methods are exposed by removing the leading HTTP_
(if it exists) and downcasing the name. For example, auth_type
will return the environment variable AUTH_TYPE
, and accept
will return the value for HTTP_ACCEPT
.
Access to cookies, including the cookies attribute.
Access to parameters, including the params attribute, and overloading []
to perform parameter value lookup by key.
The initialize_query
method, for initializing the above mechanisms, handling multipart forms, and allowing the class to be used in “offline” mode.
The Observable
module extended to DRb
. See Observable
for details.
This module has all methods of FileUtils
module, but it outputs messages before acting. This equates to passing the :verbose
flag to methods in FileUtils
.
The HTTPHeader module provides access to HTTP headers.
The module is included in:
Net::HTTPGenericRequest
(and therefore Net::HTTPRequest
).
The headers are a hash-like collection of key/value pairs called fields.
Headers may be included in:
A Net::HTTPRequest
object: the object’s headers will be sent with the request. Any fields may be defined in the request; see Setters.
A Net::HTTPResponse
object: the objects headers are usually those returned from the host. Fields may be retrieved from the object; see Getters and Iterators.
Exactly which fields should be sent or expected depends on the host; see:
A header field is a key/value pair.
A field key may be:
A string: Key 'Accept'
is treated as if it were 'Accept'.downcase
; i.e., 'accept'
.
A symbol: Key :Accept
is treated as if it were :Accept.to_s.downcase
; i.e., 'accept'
.
Examples:
req = Net::HTTP::Get.new(uri) req[:accept] # => "*/*" req['Accept'] # => "*/*" req['ACCEPT'] # => "*/*" req['accept'] = 'text/html' req[:accept] = 'text/html' req['ACCEPT'] = 'text/html'
A field value may be returned as an array of strings or as a string:
These methods return field values as arrays:
get_fields
: Returns the array value for the given key, or nil
if it does not exist.
to_hash
: Returns a hash of all header fields: each key is a field name; its value is the array value for the field.
These methods return field values as string; the string value for a field is equivalent to self[key.downcase.to_s].join(', '))
:
The field value may be set:
[]=
: Sets the value for the given key; the given value may be a string, a symbol, an array, or a hash.
add_field
: Adds a given value to a value for the given key (not overwriting the existing value).
delete
: Deletes the field for the given key.
Example field values:
String:
req['Accept'] = 'text/html' # => "text/html" req['Accept'] # => "text/html" req.get_fields('Accept') # => ["text/html"]
Symbol:
req['Accept'] = :text # => :text req['Accept'] # => "text" req.get_fields('Accept') # => ["text"]
Simple array:
req[:foo] = %w[bar baz bat] req[:foo] # => "bar, baz, bat" req.get_fields(:foo) # => ["bar", "baz", "bat"]
Simple hash:
req[:foo] = {bar: 0, baz: 1, bat: 2} req[:foo] # => "bar, 0, baz, 1, bat, 2" req.get_fields(:foo) # => ["bar", "0", "baz", "1", "bat", "2"]
Nested:
req[:foo] = [%w[bar baz], {bat: 0, bam: 1}] req[:foo] # => "bar, baz, bat, 0, bam, 1" req.get_fields(:foo) # => ["bar", "baz", "bat", "0", "bam", "1"] req[:foo] = {bar: %w[baz bat], bam: {bah: 0, bad: 1}} req[:foo] # => "bar, baz, bat, bam, bah, 0, bad, 1" req.get_fields(:foo) # => ["bar", "baz", "bat", "bam", "bah", "0", "bad", "1"]
Various convenience methods retrieve values, set values, query values, set form values, or iterate over fields.
Method []=
can set any field, but does little to validate the new value; some of the other setter methods provide some validation:
[]=
: Sets the string or array value for the given key.
add_field
: Creates or adds to the array value for the given key.
basic_auth
: Sets the string authorization header for 'Authorization'
.
content_length=
: Sets the integer length for field 'Content-Length
.
content_type=
: Sets the string value for field 'Content-Type'
.
proxy_basic_auth
: Sets the string authorization header for 'Proxy-Authorization'
.
set_range
: Sets the value for field 'Range'
.
set_form
: Sets an HTML form data set.
set_form_data
: Sets header fields and a body from HTML form data.
Method []
can retrieve the value of any field that exists, but always as a string; some of the other getter methods return something different from the simple string value:
[]
: Returns the string field value for the given key.
content_length
: Returns the integer value of field 'Content-Length'
.
content_range
: Returns the Range
value of field 'Content-Range'
.
content_type
: Returns the string value of field 'Content-Type'
.
fetch
: Returns the string field value for the given key.
get_fields
: Returns the array field value for the given key
.
main_type
: Returns first part of the string value of field 'Content-Type'
.
sub_type
: Returns second part of the string value of field 'Content-Type'
.
range
: Returns an array of Range
objects of field 'Range'
, or nil
.
range_length
: Returns the integer length of the range given in field 'Content-Range'
.
type_params
: Returns the string parameters for 'Content-Type'
.
chunked?
: Returns whether field 'Transfer-Encoding'
is set to 'chunked'
.
connection_close?
: Returns whether field 'Connection'
is set to 'close'
.
connection_keep_alive?
: Returns whether field 'Connection'
is set to 'keep-alive'
.
key?
: Returns whether a given key exists.
each_capitalized
: Passes each field capitalized-name/value pair to the block.
each_capitalized_name
: Passes each capitalized field name to the block.
each_header
: Passes each field name/value pair to the block.
each_name
: Passes each field name to the block.
each_value
: Passes each string field value to the block.
Flags for while and until loop nodes.
Flags for range and flip-flop nodes.
A module responsible for deserializing parse results.
Formats generated random numbers in many manners. When 'random/formatter'
is required, several methods are added to empty core module Random::Formatter
, making them available as Random’s instance and module methods.
Standard library SecureRandom
is also extended with the module, and the methods described below are available as a module methods in it.
Generate random hexadecimal strings:
require 'random/formatter' prng = Random.new prng.hex(10) #=> "52750b30ffbc7de3b362" prng.hex(10) #=> "92b15d6c8dc4beb5f559" prng.hex(13) #=> "39b290146bea6ce975c37cfc23" # or just Random.hex #=> "1aed0c631e41be7f77365415541052ee"
Generate random base64 strings:
prng.base64(10) #=> "EcmTPZwWRAozdA==" prng.base64(10) #=> "KO1nIU+p9DKxGg==" prng.base64(12) #=> "7kJSM/MzBJI+75j8" Random.base64(4) #=> "bsQ3fQ=="
Generate random binary strings:
prng.random_bytes(10) #=> "\016\t{\370g\310pbr\301" prng.random_bytes(10) #=> "\323U\030TO\234\357\020\a\337" Random.random_bytes(6) #=> "\xA1\xE6Lr\xC43"
Generate alphanumeric strings:
prng.alphanumeric(10) #=> "S8baxMJnPl" prng.alphanumeric(10) #=> "aOxAg8BAJe" Random.alphanumeric #=> "TmP9OsJHJLtaZYhP"
Generate UUIDs:
prng.uuid #=> "2d931510-d99f-494a-8c67-87feb05e1594" prng.uuid #=> "bad85eb9-0713-4da7-8d36-07a8e4b00eab" Random.uuid #=> "f14e0271-de96-45cc-8911-8910292a42cd"
All methods are available in the standard library SecureRandom
, too:
SecureRandom.hex #=> "05b45376a30c67238eb93b16499e50cf"
Generate a random number in the given range as Random
does
prng.random_number #=> 0.5816771641321361 prng.random_number(1000) #=> 485 prng.random_number(1..6) #=> 3 prng.rand #=> 0.5816771641321361 prng.rand(1000) #=> 485 prng.rand(1..6) #=> 3
Mixin methods for local and remote Gem::Command
options.
Mixin methods for –version and –platform Gem::Command
options.
Includes URI::REGEXP::PATTERN
Extends Fiddle::Closure
to allow for building the closure in a block
SSLServer
represents a TCP/IP server socket with Secure Sockets Layer.
Raised when an operation would resize or re-allocate a locked buffer.
Raised when the buffer cannot be allocated for some reason, or you try to use a buffer that’s not allocated.