Returns a content type string such as “text/html”. This method returns nil if Content-Type: header field does not exist.
Set
an HTML form data set.
params
The form data to set, which should be an enumerable. See below for more details.
enctype
The content type to use to encode the form submission, which should be application/x-www-form-urlencoded or multipart/form-data.
formopt
An options hash, supporting the following options:
The boundary of the multipart message. If not given, a random boundary will be used.
The charset of the form submission. All field names and values of non-file fields should be encoded with this charset.
Each item of params should respond to each
and yield 2-3 arguments, or an array of 2-3 elements. The arguments yielded should be:
* The name of the field. * The value of the field, it should be a String or a File or IO-like. * An options hash, supporting the following options, only used for file uploads: :filename :: The name of the file to use. :content_type :: The content type of the uploaded file.
Each item is a file field or a normal field. If value
is a File
object or the opt
hash has a :filename key, the item is treated as a file field.
If Transfer-Encoding is set as chunked, this sends the request using chunked encoding. Because chunked encoding is HTTP/1.1 feature, you should confirm that the server supports HTTP/1.1 before using chunked encoding.
Example:
req.set_form([["q", "ruby"], ["lang", "en"]]) req.set_form({"f"=>File.open('/path/to/filename')}, "multipart/form-data", charset: "UTF-8", ) req.set_form([["f", File.open('/path/to/filename.bar'), {filename: "other-filename.foo"} ]], "multipart/form-data", )
See also RFC 2388, RFC 2616, HTML 4.01, and HTML5
returns “type/subtype” which is MIME Content-Type. It is downcased for canonicalization. Content-Type parameters are stripped.
Returns a list of encodings in Content-Encoding field as an array of strings.
The encodings are downcased for canonicalization.
Random::Formatter#urlsafe_base64
generates a random URL-safe base64 string.
The argument n specifies the length, in bytes, of the random number to be generated. The length of the result string is about 4/3 of n.
If n is not specified or is nil, 16 is assumed. It may be larger in the future.
The boolean argument padding specifies the padding. If it is false or nil, padding is not generated. Otherwise padding is generated. By default, padding is not generated because “=” may be used as a URL delimiter.
The result may contain A-Z, a-z, 0-9, “-” and “_”. “=” is also used if padding is true.
require 'random/formatter' prng.urlsafe_base64 #=> "b4GOKm4pOYU_-BOXcrUGDg" prng.urlsafe_base64 #=> "UZLdOkzop70Ddx-IJR0ABg" prng.urlsafe_base64(nil, true) #=> "i0XQ-7gglIsHGV2_BNPrdQ==" prng.urlsafe_base64(nil, true) #=> "-M8rLhr7JEpJlqFGUMmOxg=="
See RFC 3548 for the definition of URL-safe base64.
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.
Use new_ui
for the duration of block
.
Filter’s a state’s possibilities to remove any that would not satisfy the requirements in the conflict we’ve just rewound from @param [UnwindDetails] unwind_details details of the conflict just unwound from @return [void]
Attempts to update the existing vertex’s ‘PossibilitySet` with a filtered version @return [void]
@param [DependencyState] state @param [Array] binding_requirements array of requirements @return [Boolean] whether or not the given state has any possibilities
that could satisfy the given requirements
Attempts to activate the current {#possibility} @return [void]
Generates a filtered version of the existing vertex’s ‘PossibilitySet` using the current state’s ‘requirement` @param [Object] vertex existing vertex @return [PossibilitySet] filtered possibility set
Returns the string that is used to insert a space between the tokens in a JSON
string.
Sets space to the string that is used to insert a space between the tokens in a JSON
string.