Similar to read, but raises EOFError
at end of string unless the +exception: false+ option is passed in.
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
.
Generates a String with length number of pseudo-random bytes.
Pseudo-random byte sequences generated by ::pseudo_bytes
will be unique if they are of sufficient length, but are not necessarily unpredictable.
OpenSSL::Random.pseudo_bytes(12) #=> "..."
Generates a mask value for priority levels at or below the level specified. See mask=
The total time used for garbage collection in seconds
Parses multipart form elements according to
http://www.w3.org/TR/html401/interact/forms.html#h-17.13.4.2
Returns a hash of multipart form parameters with bodies of type StringIO
or Tempfile
depending on whether the multipart form element exceeds 10 KB
params[name => body]
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 Form element with multipart encoding as a String.
Multipart encoding is used for forms that include file uploads.
action
is the action to perform. enctype
is the encoding type, which defaults to “multipart/form-data”.
Alternatively, the attributes can be specified as a hash.
multipart_form{ "string" } # <FORM METHOD="post" ENCTYPE="multipart/form-data">string</FORM> multipart_form("url") { "string" } # <FORM METHOD="post" ACTION="url" ENCTYPE="multipart/form-data">string</FORM>
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">
Generates a radio-button Input element.
name
is the name of the input field. value
is the value of the field if checked. checked
specifies whether the field starts off checked.
Alternatively, the attributes can be specified as a hash.
radio_button("name", "value") # <INPUT TYPE="radio" NAME="name" VALUE="value"> radio_button("name", "value", true) # <INPUT TYPE="radio" NAME="name" VALUE="value" CHECKED> radio_button("NAME" => "name", "VALUE" => "value", "ID" => "foo") # <INPUT TYPE="radio" NAME="name" VALUE="value" ID="foo">
Add a new protocol to the DRbProtocol
module.
Add a new protocol to the DRbProtocol
module.
Returns a Hash
consisting of header names and array of values. e.g. {“cache-control” => [“private”],
"content-type" => ["text/html"], "date" => ["Wed, 22 Jun 2005 22:11:50 GMT"]}
Set
an HTML form data set. params
is the form data set; it is an Array of Arrays or a Hash
+enctype is the type to encode the form data set. It is application/x-www-form-urlencoded or multipart/form-data. formopt
is an optional hash to specify the detail.
the boundary of the multipart message
the charset of the message. All names and the values of non-file fields are encoded as the charset.
Each item of params is an array and contains following items:
name
the name of the field
value
the value of the field, it should be a String or a File
opt
an optional hash to specify additional information
Each item is a file field or a normal field. If value
is a File
object or the opt
have a filename key, the item is treated as a file field.
If Transfer-Encoding is set as chunked, this send the request in chunked encoding. Because chunked encoding is HTTP/1.1 feature, you must confirm the server to support HTTP/1.1 before sending it.
Example:
http.set_form([["q", "ruby"], ["lang", "en"]])
See also RFC 2388, RFC 2616, HTML 4.01, and HTML5
returns a Time
that represents the Last-Modified field.
A node-set is converted to a string by returning the concatenation of the string-value of each of the children of the node in the node-set that is first in document order. If the node-set is empty, an empty string is returned.
Fixed by Mike Stok
Kouhei fixed this too
UNTESTED
UNTESTED