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
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 a Time
that represents the Last-Modified field.
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.
Creates a new key pair of the specified algorithm
. RSA, DSA, and EC are supported.
Signs expired_certificate
with private_key
if the keys match and the expired certificate was self-signed.
Returns a Gem::Security::TrustDir
which wraps the directory where trusted certificates live.
Enumerates the trusted certificates via Gem::Security::TrustDir
.
Simple deprecation method that deprecates name
by wrapping it up in a dummy method. It warns on each call to the dummy method telling the user of repl
(unless repl
is :none) and the Rubygems version that it is planned to go away.
Simple deprecation method that deprecates name
by wrapping it up in a dummy method. It warns on each call to the dummy method telling the user of repl
(unless repl
is :none) and the Rubygems version that it is planned to go away.
If response
is an HTTP Success (2XX) response, yields the response if a block was given or shows the response body to the user.
If the response was not successful, shows an error to the user including the error_prefix
and the response body.
Wraps text
to wrap
characters and optionally indents by indent
characters