Returns the source encoding as an encoding object.
Note that the result may not be equal to the source encoding of the encoding converter if the conversion has multiple steps.
ec = Encoding::Converter.new("ISO-8859-1", "EUC-JP") # ISO-8859-1 -> UTF-8 -> EUC-JP begin ec.convert("\xa0") # NO-BREAK SPACE, which is available in UTF-8 but not in EUC-JP. rescue Encoding::UndefinedConversionError p $!.source_encoding #=> #<Encoding:UTF-8> p $!.destination_encoding #=> #<Encoding:EUC-JP> p $!.source_encoding_name #=> "UTF-8" p $!.destination_encoding_name #=> "EUC-JP" end
Returns the corresponding ASCII compatible encoding.
Returns nil if the argument is an ASCII compatible encoding.
“corresponding ASCII compatible encoding” is an ASCII compatible encoding which can represents exactly the same characters as the given ASCII incompatible encoding. So, no conversion undefined error occurs when converting between the two encodings.
Encoding::Converter.asciicompat_encoding("ISO-2022-JP") #=> #<Encoding:stateless-ISO-2022-JP> Encoding::Converter.asciicompat_encoding("UTF-16BE") #=> #<Encoding:UTF-8> Encoding::Converter.asciicompat_encoding("UTF-8") #=> nil
Returns the source encoding as an Encoding
object.
A wrapper class to use a StringIO
object as the body and switch to a TempFile when the passed threshold is passed. Initialize the data from the query.
Handles multipart forms (in particular, forms that involve file uploads). Reads query parameters in the @params field, and cookies into @cookies.
As for each_header
, except the keys are provided in capitalized form.
Note that header names are capitalized systematically; capitalization may not match that used by the remote HTTP
server in its response.
Set
the Authorization: header for “Basic” authorization.
Helper method.
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.
This code is based directly on the Text
gem implementation Returns a value representing the “cost” of transforming str1 into str2
Simple wrapper for providing basic authentication for a request. When called with a request req
, response res
, authentication realm
and block
the block will be called with a username
and password
. If the block returns true the request is allowed to continue, otherwise an HTTPStatus::Unauthorized error is raised.
Is code
a client error status?
Is code
a client error status?
Normalizes a request path. Raises an exception if the path cannot be normalized.
Normalizes a request path. Raises an exception if the path cannot be normalized.
Creates TCP server sockets bound to address
:port
and returns them.
It will create IPV4 and IPV6 sockets on all interfaces.