Class: Protocol::Multipart::FormData
- Includes:
- Escape
- Defined in:
- lib/protocol/multipart/form_data.rb
Overview
FormData class for handling multipart/form-data format used in HTTP forms. Extends Mixed to provide specific support for form fields with names and values.
Instance Attribute Summary
Attributes inherited from Mixed
#The boundary string used to separate parts., #The parts of the body., #boundary, #parts
Attributes inherited from Part
Class Method Summary collapse
-
.mime_type ⇒ Object
Returns the MIME type for form data.
Instance Method Summary collapse
-
#add_field(name, value, headers = {}) ⇒ Object
Adds a form field to the multipart form data.
Methods included from Escape
#escape_field_name, #unescape_field_name
Methods inherited from Mixed
Methods inherited from Part
#The headers as name/value pairs.=, #call, #initialize
Constructor Details
This class inherits a constructor from Protocol::Multipart::Mixed
Class Method Details
.mime_type ⇒ Object
Returns the MIME type for form data.
20 21 22 |
# File 'lib/protocol/multipart/form_data.rb', line 20 def self.mime_type "multipart/form-data" end |
Instance Method Details
#add_field(name, value, headers = {}) ⇒ Object
Adds a form field to the multipart form data.
30 31 32 33 34 35 36 37 38 |
# File 'lib/protocol/multipart/form_data.rb', line 30 def add_field(name, value, headers = {}) headers = headers.merge( "content-disposition" => "form-data; name=\"#{escape_field_name name}\"" ) StringPart.new(headers, value).tap do |part| @parts << part end end |