@@ -423,30 +423,50 @@ def set_form_data(params, sep = '&')
423423 alias form_data = set_form_data
424424
425425 # Set an HTML form data set.
426- # +params+ is the form data set; it is an Array of Arrays or a Hash
427- # +enctype is the type to encode the form data set.
428- # It is application/x-www-form-urlencoded or multipart/form-data.
429- # +formopt+ is an optional hash to specify the detail.
426+ # +params+ :: The form data to set, which should be an enumerable.
427+ # See below for more details.
428+ # +enctype+ :: The content type to use to encode the form submission,
429+ # which should be application/x-www-form-urlencoded or
430+ # multipart/form-data.
431+ # +formopt+ :: An options hash, supporting the following options:
432+ # :boundary :: The boundary of the multipart message. If
433+ # not given, a random boundary will be used.
434+ # :charset :: The charset of the form submission. All
435+ # field names and values of non-file fields
436+ # should be encoded with this charset.
430437 #
431- # boundary:: the boundary of the multipart message
432- # charset:: the charset of the message. All names and the values of
433- # non-file fields are encoded as the charset .
434- #
435- # Each item of params is an array and contains following items:
436- # +name+:: the name of the field
437- # +value+:: the value of the field, it should be a String or a File
438- # +opt+:: an optional hash to specify additional information
438+ # Each item of params should respond to +each+ and yield 2-3 arguments,
439+ # or an array of 2-3 elements. The arguments yielded should be:
440+ # * The name of the field .
441+ # * The value of the field, it should be a String or a File or IO-like.
442+ # * An options hash, supporting the following options, only
443+ # used for file uploads:
444+ # :filename :: The name of the file to use.
445+ # :content_type :: The content type of the uploaded file.
439446 #
440447 # Each item is a file field or a normal field.
441- # If +value+ is a File object or the +opt+ have a filename key,
448+ # If +value+ is a File object or the +opt+ hash has a : filename key,
442449 # the item is treated as a file field.
443450 #
444- # If Transfer-Encoding is set as chunked, this send the request in
451+ # If Transfer-Encoding is set as chunked, this sends the request using
445452 # chunked encoding. Because chunked encoding is HTTP/1.1 feature,
446- # you must confirm the server to support HTTP/1.1 before sending it.
453+ # you should confirm that the server supports HTTP/1.1 before using
454+ # chunked encoding.
447455 #
448456 # Example:
449- # http.set_form([["q", "ruby"], ["lang", "en"]])
457+ # req.set_form([["q", "ruby"], ["lang", "en"]])
458+ #
459+ # req.set_form({"f"=>File.open('/path/to/filename')},
460+ # "multipart/form-data",
461+ # charset: "UTF-8",
462+ # )
463+ #
464+ # req.set_form([["f",
465+ # File.open('/path/to/filename.bar'),
466+ # {filename: "other-filename.foo"}
467+ # ]],
468+ # "multipart/form-data",
469+ # )
450470 #
451471 # See also RFC 2388, RFC 2616, HTML 4.01, and HTML5
452472 #
0 commit comments