Checks the path v
component for RFC2396 compliance and against the URI::Parser Regexp
for :ABS_PATH and :REL_PATH.
Can not have a opaque component defined, with a path component defined.
Checks the opaque v
component for RFC2396 compliance and against the URI::Parser Regexp
for :OPAQUE.
Can not have a host, port, user, or path component defined, with an opaque component defined.
Merges a base path base
, with relative path rel
, returns a modified base path.
Calls the given block once for each key
, value
pair in the database.
Returns self
.
Invoked by Process::Status.wait
in order to wait for a specified process. See that method description for arguments description.
Suggested minimal implementation:
Thread.new do Process::Status.wait(pid, flags) end.value
This hook is optional: if it is not present in the current scheduler, Process::Status.wait
will behave as a blocking method.
Expected to return a Process::Status
instance.
Invoked by IO#read
or IO#Buffer.read to read length
bytes from io
into a specified buffer
(see IO::Buffer
) at the given offset
.
The length
argument is the “minimum length to be read”. If the IO
buffer size is 8KiB, but the length
is 1024
(1KiB), up to 8KiB might be read, but at least 1KiB will be. Generally, the only case where less data than length
will be read is if there is an error reading the data.
Specifying a length
of 0 is valid and means try reading at least once and return any available data.
Suggested implementation should try to read from io
in a non-blocking manner and call io_wait
if the io
is not ready (which will yield control to other fibers).
See IO::Buffer
for an interface available to return data.
Expected to return number of bytes read, or, in case of an error, -errno
(negated number corresponding to system’s error code).
The method should be considered experimental.
Invoked by IO#pread
or IO::Buffer#pread
to read length
bytes from io
at offset from
into a specified buffer
(see IO::Buffer
) at the given offset
.
This method is semantically the same as io_read
, but it allows to specify the offset to read from and is often better for asynchronous IO
on the same file.
The method should be considered experimental.
Invoked by IO.select
to ask whether the specified descriptors are ready for specified events within the specified timeout
.
Expected to return the 3-tuple of Array
of IOs that are ready.
Returns the one-character string which cause Encoding::UndefinedConversionError
.
ec = Encoding::Converter.new("ISO-8859-1", "EUC-JP") begin ec.convert("\xa0") rescue Encoding::UndefinedConversionError puts $!.error_char.dump #=> "\xC2\xA0" p $!.error_char.encoding #=> #<Encoding:UTF-8> 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
Inserts string into the encoding converter. The string will be converted to the destination encoding and output on later conversions.
If the destination encoding is stateful, string is converted according to the state and the state is updated.
This method should be used only when a conversion error occurs.
ec = Encoding::Converter.new("utf-8", "iso-8859-1") src = "HIRAGANA LETTER A is \u{3042}." dst = "" p ec.primitive_convert(src, dst) #=> :undefined_conversion puts "[#{dst.dump}, #{src.dump}]" #=> ["HIRAGANA LETTER A is ", "."] ec.insert_output("<err>") p ec.primitive_convert(src, dst) #=> :finished puts "[#{dst.dump}, #{src.dump}]" #=> ["HIRAGANA LETTER A is <err>.", ""] ec = Encoding::Converter.new("utf-8", "iso-2022-jp") src = "\u{306F 3041 3068 2661 3002}" # U+2661 is not representable in iso-2022-jp dst = "" p ec.primitive_convert(src, dst) #=> :undefined_conversion puts "[#{dst.dump}, #{src.dump}]" #=> ["\e$B$O$!$H".force_encoding("ISO-2022-JP"), "\xE3\x80\x82"] ec.insert_output "?" # state change required to output "?". p ec.primitive_convert(src, dst) #=> :finished puts "[#{dst.dump}, #{src.dump}]" #=> ["\e$B$O$!$H\e(B?\e$B!#\e(B".force_encoding("ISO-2022-JP"), ""]
Iterates over keys and values. Note that unlike other collections, each
without block isn’t supported.
Returns a new instance of the C struct with the value ty
at the addr
address.
Returns a new Fiddle::Pointer
instance at the memory address of the given name
symbol.
Raises a DLError
if the name
doesn’t exist.
Consumes size bytes from the buffer
Reads at most maxlen bytes in the non-blocking manner.
When no data can be read without blocking it raises OpenSSL::SSL::SSLError
extended by IO::WaitReadable
or IO::WaitWritable
.
IO::WaitReadable
means SSL
needs to read internally so read_nonblock
should be called again when the underlying IO
is readable.
IO::WaitWritable
means SSL
needs to write internally so read_nonblock
should be called again after the underlying IO
is writable.
OpenSSL::Buffering#read_nonblock
needs two rescue clause as follows:
# emulates blocking read (readpartial). begin result = ssl.read_nonblock(maxlen) rescue IO::WaitReadable IO.select([io]) retry rescue IO::WaitWritable IO.select(nil, [io]) retry end
Note that one reason that read_nonblock
writes to the underlying IO
is when the peer requests a new TLS/SSL handshake. See openssl the FAQ for more details. www.openssl.org/support/faq.html
By specifying a keyword argument exception to false
, you can indicate that read_nonblock
should not raise an IO::Wait*able exception, but return the symbol :wait_writable
or :wait_readable
instead. At EOF, it will return nil
instead of raising EOFError
.
Writes s to the buffer. When the buffer is full or sync
is true the buffer is flushed to the underlying socket.
Generate an Image Button Input element as a string.
src
is the URL of the image to use for the button. name
is the input name. alt
is the alternative text for the image.
Alternatively, the attributes can be specified as a hash.
image_button("url") # <INPUT TYPE="image" SRC="url"> image_button("url", "name", "string") # <INPUT TYPE="image" SRC="url" NAME="name" ALT="string"> image_button("SRC" => "url", "ALT" => "string") # <INPUT TYPE="image" SRC="url" ALT="string">
Generate a Password Input element as a string.
name
is the name of the input field. value
is its default value. size
is the size of the input field display. maxlength
is the maximum length of the inputted password.
Alternatively, attributes can be specified as a hash.
password_field("name") # <INPUT TYPE="password" NAME="name" SIZE="40"> password_field("name", "value") # <INPUT TYPE="password" NAME="name" VALUE="value" SIZE="40"> password_field("password", "value", 80, 200) # <INPUT TYPE="password" NAME="name" VALUE="value" SIZE="80" MAXLENGTH="200"> password_field("NAME" => "name", "VALUE" => "value") # <INPUT TYPE="password" NAME="name" VALUE="value">
Generate a sequence of radio button Input elements, as a String
.
This works the same as checkbox_group()
. However, it is not valid to have more than one radiobutton in a group checked.
radio_group("name", "foo", "bar", "baz") # <INPUT TYPE="radio" NAME="name" VALUE="foo">foo # <INPUT TYPE="radio" NAME="name" VALUE="bar">bar # <INPUT TYPE="radio" NAME="name" VALUE="baz">baz radio_group("name", ["foo"], ["bar", true], "baz") # <INPUT TYPE="radio" NAME="name" VALUE="foo">foo # <INPUT TYPE="radio" CHECKED NAME="name" VALUE="bar">bar # <INPUT TYPE="radio" NAME="name" VALUE="baz">baz radio_group("name", ["1", "Foo"], ["2", "Bar", true], "Baz") # <INPUT TYPE="radio" NAME="name" VALUE="1">Foo # <INPUT TYPE="radio" CHECKED NAME="name" VALUE="2">Bar # <INPUT TYPE="radio" NAME="name" VALUE="Baz">Baz radio_group("NAME" => "name", "VALUES" => ["foo", "bar", "baz"]) radio_group("NAME" => "name", "VALUES" => [["foo"], ["bar", true], "baz"]) radio_group("NAME" => "name", "VALUES" => [["1", "Foo"], ["2", "Bar", true], "Baz"])
Like each_header
, but the keys are returned in capitalized form.
Net::HTTPHeader#canonical_each
is an alias for Net::HTTPHeader#each_capitalized
.
Returns the value of field 'Content-Length'
as an integer, or nil
if there is no such field; see Content-Length request header:
res = Net::HTTP.get_response(hostname, '/nosuch/1') res.content_length # => 2 res = Net::HTTP.get_response(hostname, '/todos/1') res.content_length # => nil